Latest Posts

Topic: I am lost

Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-17, 09:28

Hello,

No, not as much lost as that. face-wink.png

Just a certain dichotomy between two languages. I am preparing a scenario where there must be explanatory texts.

I think these texts in French, I prepare my text in French, I translate the text in English to put it in the text.lua file and I run the game to see if the displays correspond to my expectations. Of course the text that appears is in English and I have to make a big effort to find where I am in the scenario.

All this being explained, is it possible that I start using a .mo file which would allow me to have the texts in French. If so, where should I put it and under which directory?

Otherwise I will have to separate my brain in two, a French part, an English part. I'm afraid I won't endure this operation long before I'm going crazy. face-smile-big.png


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1304
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-04-17, 12:05

The .mo file goes in

data/locale/fr/LC_MESSAGES/scenario_xy.wmf.mo

(where you can replace xy with whatever you like). Your scenario must then include the textdomain by calling

push_textdomain("scenario_xy.wmf")

at the start of your scenario's init.lua.


Top Quote
Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-17, 17:59

Thank you, I will keep my sanity. face-smile.png

Just a little thing, looking at the 'init.lua' of other scenarii I found 'set_textdomain' instead of 'push textdomain'. Does it make a fundamental difference?


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1304
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-04-17, 18:37

set_textdomain has been deprecated and will be removed eventually. All lua scripting should always use push_textdomain instead. See https://www.widelands.org/documentation/autogen_globals/#string.push_textdomain


Top Quote
Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-17, 20:03

Ok, I change.

When I have to learn a new language, I always take inspiration from what has been written before, I don't necessarily read all the documentation from A to Z, especially if it is only in English. face-smile.png


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-17, 23:31

Oups,

Sorry to say that but when I use : set_textdomain("scenario_aa_survival.wmf"), all is good.

when I use : push_textdomain("scenario_aa_survival.wmf")


and if I use : push_textdomain("scenario_aa_survival.wmf",addon=false) or addon=true


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1304
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-04-18, 12:34

Perhaps you're using an outdated Widelands version, which does not have these functions yet?

If you want to write the scenario specifically for this older version, just use set_textdomain instead. But if you want to support both old and new versions for maximum user friendliness you could use this:

if push_textdomain then push_textdomain("scenario_aa_survival.wmf") else set_textdomain("scenario_aa_survival.wmf") end

Btw "addon" is just the name of a parameter so the complete function call is actually

 push_textdomain("scenario_aa_survival.wmf", false)
 push_textdomain("scenario_aa_survival.wmf", true)

You only need to set the second parameter if you want to package your mission as an add-on.


Top Quote
Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-18, 15:13

I use build21-26.14

I don't know if it is a very old version but it is the last version I found in the openSuse repository. If there is a new stable version somewhere I'm ready to install it. face-wink.png

Ok for the term "addon", I haven't understand.

PS: I had never seen a line from Lua before last week, I don't know how to interpret error messages yet. face-smile.png


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote
Nordfriese
Avatar
Joined: 2017-01-17, 18:07
Posts: 1304
Ranking
One Elder of Players
Location: 0x55555d3a34c0
Posted at: 2021-04-18, 15:45

Build21 is the most recent stable release (published 2020-07-18) – it's too easy to forget the pace at which development happens face-grin.png The next stable release (Widelands 1.0) will be published this spring. It contains a number of major changes to the Lua API, with the intention to offer a more stable (and forward-compatible) API from version 1.0 onwards.

Note that our online documentation always refers to the most recent development version; it is assumed and recommended that most people who develop game content will be using the latest state-of-the-art rather than a stable release.


Top Quote
Atanase
Avatar
Joined: 2021-04-15, 13:33
Posts: 126
Ranking
At home in WL-forums
Location: Béarn (France)
Posted at: 2021-04-18, 15:57

I understand very well, but ...

Please let me some time to be at the top and to use the "latest state-of-the-art" release. face-smile.png

I risk having enough problems with a language that I do not yet master (Lua) without taking the risk of having the errors of an unstable version.

Soon, very soon, I promise you that I will upgrade to the latest version stable or not. face-smile-big.png


La connaissance ne vaut que si elle est partagée par le plus grand nombre.
---------------------------------------
Knowledge is only valuable if it is shared by the greatest number.

Top Quote