Using a translatable string from Vanilla

Discussion of Lua and LuaWML support, development, and ideas.

Moderators: Forum Moderators, Developers

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Using a translatable string from Vanilla

Post by Choicerer » June 14th, 2018, 1:18 pm

I'd like to use some translatable strings from vanilla (specifically Enemy, Owned, Allied) that get shown under village description
in lua.theme_items. But I have no idea what those strings would be called, or how I should go on about using them.

EDIT:
In the source code, they appear to be functions inside the terrain_type class... I think they might be returning "Allied Village", not just "Allied", but I could still extract the first word in lua (that would work nicely, maybe not that nicely in French, Spanish and a couple of other languages :D ) .

SOLUTION:

Got it. The text domain is #textdomain wesnoth and the variable name _"Enemy village" (case sensitive)

User avatar
Celtic_Minstrel
Developer
Posts: 1148
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Using a translatable string from Vanilla

Post by Celtic_Minstrel » June 22nd, 2018, 3:16 am

To clarify: You just need to use the same textdomain that was in effect when the string was used in core, then copy-paste the whole string verbatim. That's it. If the string is used in C++ (rather than WML), the textdomain is defined by a line such as #define GETTEXT_TEXTDOMAIN "wesnoth-lib", and if there's no such line then it's in the "wesnoth" textdomain.

Extracting a word from a translatable string is highly inadvisable, however. Like you said, it's not gonna work for languages other than English.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 22nd, 2018, 3:24 pm

Yeah, thanks for the clarification. It does work for the languages that translate "enemy village" to two words nicely. Yeah, it messes up the tenses, cases whatnot but for the purposes of this mod it was especially important that in MP regardless of what language the player uses they can read the labels to know in advance what faction their enemies have drawn.
This way, it's a few lines of code and the mod works with almost any wesnoth client language AND any faction from any era. As opposed to adding thousands of strings for every language/custom vanilla faction and wasting my life and in the process making people who use other languages in MP suffer.

Landiss
Posts: 33
Joined: May 18th, 2018, 6:48 pm

Re: Using a translatable string from Vanilla

Post by Landiss » June 22nd, 2018, 8:02 pm

Yeah, that's really not a good idea. You are going to get "village" in some languages, not the "enemy". It would be better to keep it in English.

User avatar
Celtic_Minstrel
Developer
Posts: 1148
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Using a translatable string from Vanilla

Post by Celtic_Minstrel » June 23rd, 2018, 12:14 am

As Landiss said, many languages reverse the order of the words, so just taking the first word still won't give you the right answer in all languages that translate it as exactly two words. And what about languages that translate it as three words, or one word? Or even more words?
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 23rd, 2018, 10:11 am

Guys, I'm under the impression you haven't read my posts in their entirety.
Landiss wrote:
June 22nd, 2018, 8:02 pm
Yeah, that's really not a good idea. You are going to get "village" in some languages, not the "enemy". It would be better to keep it in English.
I just said that in my first post (under EDIT).
Celtic_Minstrel wrote:
June 23rd, 2018, 12:14 am
As Landiss said, many languages reverse the order of the words, so just taking the first word still won't give you the right answer in all languages that translate it as exactly two words. And what about languages that translate it as three words, or one word? Or even more words?
This I said in the second sentence of my response to your initial reply. Yeah, it doesn't work for Japanese, Chinese cause they don't use whitespaces. Finnish? I think they tend to attach a lot of suffixes to their words, but that's just my guess. And yeah, I'm sure there are languages I've never heard about that would use some sort of mandatory defining article and make it 3 words.

But! You don't realise, but I already have implemented this system. It's called the Architecture Mod. Quoting myself from the thread:
Choicerer wrote:
June 14th, 2018, 4:43 pm
Works nicely for the languages with noun_adjective order such as French, as well. Doesn't work for Japanese and Chinese.


https://github.com/Choicerer/Architectu ... ms.lua#L12

See, I already have implemented a function that extracts the second word, not the first for the languages that I know use postpositive adjectives as the norm. It still takes much less effort than manually implementing translations, especially since I don't speak all those languages (oh, and I have no idea how to generate or read those .pot files).

Now after some googling I've found this:
http://wals.info/feature/87A#2/10.5/43.6
Really nice, eh? Well, seems I've overlooked Romanian, Farsi and a lot of others. Another thing is the languages that aren't translated to a large extent don't show up in 1.14 if you don't use a console attribute.

Landiss
Posts: 33
Joined: May 18th, 2018, 6:48 pm

Re: Using a translatable string from Vanilla

Post by Landiss » June 23rd, 2018, 10:33 am

I thought you were talking about issues relating to gender and so on, not about getting completely wrong word.

As a translator when I see what you are doing I feel like white mage watching necromancer doing some dark rituals. It's disturbing.

It's simply more complicated than that. For example, in Polish it could be either adjective-noun or noun-adjective, depending on style and context. For this particular string the translation is noun-adjective, so the opposite of what is said in that page you linked.

What is it exactly that you are trying to achieve?

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 23rd, 2018, 12:21 pm

Landiss wrote:
June 23rd, 2018, 10:33 am
As a translator when I see what you are doing I feel like white mage watching necromancer doing some dark rituals. It's disturbing.
I know what you mean. In most cases this method fails to achieve grammatical correctness and the descriptions end up sounding silly.
Landiss wrote:
June 23rd, 2018, 10:33 am
It's simply more complicated than that. For example, in Polish it could be either adjective-noun or noun-adjective, depending on style and context. For this particular string the translation is noun-adjective, so the opposite of what is said in that page you linked.
No, sorry, in Polish it's actually prepositive in most cases, and in this particular case as well. Do you speak Polish? Wioska własna? That makes no sense at all. (Aside from the fact how often postpositive gets used by people who are trying to sound professional, sometimes it sounds really absurd and funny).

Unless you thought about Wioska wroga, but in that case wroga isn't an adjective, it's a possessive noun, which follows different grammatical rules. Rest assured, the people who compiled that list are able to tell the difference between an adjective and a possessive noun.
Landiss wrote:
June 23rd, 2018, 10:33 am
What is it exactly that you are trying to achieve?
I encourage you to read my posts in this thread. Then you would know why I prefer this method over trying to translate the strings into gramatically correct descriptions in other languages. You'd know as well what mod this is for, since I mentioned that a couple of hours ago in my last post. AND you would know I have already implemented the code, I said that in the post you're replying to as well.
If you're trying to offer support, it helps to get familiar with the issue in question.

EDIT:
You're right, though, in Polish they use wioska sojusznika and wioska wroga but twoja wioska. So both orders and not a single adjective. But I'd say Polish is a rare case where sometimes the possessive noun/pronoun is preferred over an adjective...

Landiss
Posts: 33
Joined: May 18th, 2018, 6:48 pm

Re: Using a translatable string from Vanilla

Post by Landiss » June 23rd, 2018, 1:08 pm

There is no need to get defensive, I'm not attacking you. I was just curious and I did read your posts in this thread.

You are correct about Polish in this case, I mixed it up, because Polish translation is "wioska przeciwnika". Of course that is not adjective, but it does mean your method would fail for this. Also, if you are Polish, you must know that it's not always adjective-noun - and not because people want to sound smart... But I don't want to go further into this, I was only pointing out it's not as simple as that list makes it look like.

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 23rd, 2018, 1:21 pm

I'm not being defensive, I'm being annoyed, because I expect people to read the posts they're replying to if they want to offer support rather than skimming over them and then asking what I'm trying to achieve when I have already explained this nicely for you in the previous post, as well as for Celtic in the post before that AND the fact I have already achieved what I wanted, the first post says solved and if you're asking that then you didn't even read it.
All you've been doing is asking me to repeat myself over an issue that's already solved anyway, i.e wasting my time.

Landiss
Posts: 33
Joined: May 18th, 2018, 6:48 pm

Re: Using a translatable string from Vanilla

Post by Landiss » June 23rd, 2018, 1:38 pm

You assume I asked, because I didn't read. I asked, because the information you provided was not detailed enough. You don't have any obligation to answer my questions (and I'm not going to ask further), but that doesn't give you a right to be aggressive. Anyway, I'm not going to continue this discussion.

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 23rd, 2018, 1:46 pm

It was more than detailed enough. You are being defensive now. Do you really expect me to quote every sentence you overlooked in response to your questions? Well, I'm not gonna do that, because I've already spent too much time repeating myself. But you might wanna consider reading the posts in the thread you are trying to offer help attentively, because otherwise you come across as disrespectful and end up wasting people's time.

User avatar
Celtic_Minstrel
Developer
Posts: 1148
Joined: August 3rd, 2012, 11:26 pm
Contact:

Re: Using a translatable string from Vanilla

Post by Celtic_Minstrel » June 23rd, 2018, 6:50 pm

Honestly, if you want to make sure it's translated into all the major languages, it would probably be better to actually use a string in your own textdomain and provide the po files for the translations. It's only three words, so I imagine providing all those translations shouldn't be too difficult.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.

Choicerer
Posts: 238
Joined: April 29th, 2017, 11:37 pm

Re: Using a translatable string from Vanilla

Post by Choicerer » June 23rd, 2018, 7:57 pm

I guess you're right, I could use Google Translate or even read up(!) on those languages when in doubt and come up with less ridiculously sounding descriptions. I suppose I've been put off by having to figure out how to generate those po files, but I should probably get round to it and do that later.

On the other hand, this way I can display any custom faction as well, and there are tons of them. So perhaps a better way to do it would be attaching the faction, uninflected in parentheses, to the translated string.

shevegen
Posts: 158
Joined: June 3rd, 2004, 4:35 pm

Re: Using a translatable string from Vanilla

Post by shevegen » June 29th, 2018, 7:54 pm

> suppose I've been put off by having to figure out how to generate those po files, but I should probably get round to
> it and do that later.

I myself am a native german speaker but I only ever only play in english. I understand that it makes sense to want to
broaden the user base for wesnoth, so translations are used, but personally, I am always fine with english and never
use the po files. A lot of effort goes into maintaining all po files when the simpler variant may be for people to just
learn english properly in the long run. :D

To the usability situation, if I understand it correctly you want to show additional text to or below village tiles? Perhaps
it may be useful to have this displayed more towards village-tile information e. g. on the right hand side. There should
be more space there and people could put more content for special tiles there as well. A bit similar to my
backpack/inventory suggestion to units that wear/wield stuff - the UI of wesnoth presently is a bit limited in my opinion
in general. Big flashy fonts on the game map are not ideal either, IMO. There is a lot of room for small improvements
to the UI.

Post Reply