IncredibleHannes / TPF2-Timetables

The Timetable mod for Transport Fever 2
GNU General Public License v3.0
32 stars 19 forks source link

Multi lang support #5

Closed muggy83 closed 3 years ago

muggy83 commented 3 years ago

Added i18n Stings in strings.lua Exchanged original strings with global i18n attributes Knows Bugs in the UI generation. Combobox works with internationalized string, the tables and the windows itself not yet.

muggy83 commented 3 years ago

Take a look into it. The provided solution is based on the in-game function, that the strings.lua file in the root directory is parsed and it´s return is interpreted accourding the game-setting of the language. The strings are then global variables in the context of the mod. I don´t really get the problem fixed, why comboBox:addItem(_("arr_dep_i18n")) works, but local sortAll = api.gui.comp.ToggleButton.new(api.gui.comp.TextView.new(_("all_i18n"))) not.

IncredibleHannes commented 3 years ago

looks good so far, as you mentioned minor bug in the window header/tabs. image Not sure about the translation "Unbeündelte Zeit" I suggest: "Abfahrts Intervall"or "Tackt Zeit"

muggy83 commented 3 years ago

Correct, "Unbunch" and "Unbunch Time" is one point we should discuss in German. Your suggestions are definitly better :-)

As I´m a noob to lua (and not an computer scientist, maybe you have an idea, why the the global variables are working in some cases, in some cases not. It reminds me of a problem I had many years ago in C++/CUDA, that some methods/funtions don´t allow variables but fixed stings. In parallel I try find an example in other mods, how they solved the problem.

IncredibleHannes commented 3 years ago

I played around a little bit with your code and you are right, the function seems to behave very strangely..
It seems like the function returns different results depending on where its called. I put some prints of the same key in different parts of the code and it gave me differently strings depending on where I put the print statements. This at least shows that the keys are not the problem, rather where the location where the "
" function is called

IncredibleHannes commented 3 years ago

Defining the strings that are not working globally and using them later seems to solve the problem ;)

muggy83 commented 3 years ago

Oh really? I thought I have tested that as well. Can you give some lines of code as an example? Then I´ll fix it on my side.

IncredibleHannes commented 3 years ago
local UIStrings = {
    lines = _("lines_i18n"),
    ...
}

add this on line 21

and change this (Arround line 185): menu.tabWidget:addTab(api.gui.comp.TextView.new(_("lines_i18n")), wrapper) to menu.tabWidget:addTab(api.gui.comp.TextView.new(UIStrings.lines), wrapper)

muggy83 commented 3 years ago

I added and fixed everything from my side and tested. It should be fine now!

Gordon-Dry commented 3 years ago

I still got this: Screen-2021-03-02_13-30-04 see cursor

IncredibleHannes commented 3 years ago

Thanks, will have a look, might be due to merge conflicts I resolved on this

Gordon-Dry commented 3 years ago

Also this one Screen-2021-03-03_01-20-31 with develop branch.