Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add translations #101

Closed
Roberto5 opened this issue Oct 27, 2013 · 7 comments
Closed

Add translations #101

Roberto5 opened this issue Oct 27, 2013 · 7 comments

Comments

@Roberto5
Copy link
Contributor

Can we add support for multiple languages to this mod?

@ShadowNinja
Copy link
Member

Yes, we can use kaeza's intllib mod for internationalization. Would you be able to add translations?

@aracnus
Copy link

aracnus commented Oct 27, 2013

I would like to translate it to Brazilian Portuguese.

@Roberto5
Copy link
Contributor Author

yes, i can add translations, i have see on mod more ores, it control if mod intllib is loaded and set the function S, else s=function(s) return s

local S
if (minetest.get_modpath("intllib")) then
        dofile(minetest.get_modpath("intllib").."/intllib.lua")
        S = intllib.Getter(minetest.get_current_modname())
        else
        S = function ( s ) return s end
end

every string must be insert in function S

S("string to translate")
S("my param %s "):format(S("param"))

my hint is to use a translation simbol.
for example

S("GOLD")
S("GOLD_DESC")

locale/en.txt

GOLD = gold
GOLD_DESC = gold is a mineral

is redundant, but we can take en.txt for make easy and total translation

locale/it.txt

GOLD = oro
GOLD_DESC = l'oro è un minerale

this is importat edit, i want talk before write

@ShadowNinja
Copy link
Member

No, that isn't how intllib is used. It should be used like this:
name = S("Gold")
And then in a translation file:
Gold = Aurum
That way if a translation is not found it returns "Gold" and not "GOLD_NAME".
Your usage of format() is also incorrect, it should be used like this:
S("Electric Furnace %s"):format(percent)
That is, you normally don't translate arguments to format, you just translate it in the original string.
Of course in this case you could just use concatenation, format syntax is more useful when you want to embed strings into the middle of a translation.
format() and concatenation should be used for untranslatable strings like numbers, usually that are dynamic.
I am discussing intllib with kaeza right now, and before we add translation files we will need to have support for it in the code.

@Roberto5
Copy link
Contributor Author

in your method we must write on terminal this command
grep -o -r 'S("'.*'")' * > locale/en.txt

for search every string to translate.

@ShadowNinja
Copy link
Member

@pagliaccio: With your method, yes. We would then have to translate all of the constants. However if a translation is not found the original string is returned, so you have to use real strings.

@ShadowNinja
Copy link
Member

I have pushed support for intllib. @aracnus and @pagliaccio: You can begin work on your translations. Use locale/template.txt to start. Once you have finished you can pull-request it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants