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

Using S(variable) put translations in not used anymore section #8

Open
louisroyer opened this issue Mar 14, 2020 · 3 comments
Open

Comments

@louisroyer
Copy link
Contributor

Add a syntax in .tr files to let the user say some translations are associated with a S(variable) call in a file. Since it is not trivial to detect variable content unless we run the script (and this is a bad idea), this kind of translations needs to be reviewed manually and not be confused with not used anymore translation. When detection of a S(variable) in a file occurs but no string is associated to the variable yet, the script could emit a warning and write a warning in the "not used anymore" section.

@FaceDeer
Copy link
Collaborator

To be clear, you're talking about a scenario like this?

local baseText = "this string should be translated"
local translatedText = S(baseText)

And then manually adding

#actuallyUsedTag
this string should be translated=

To the template and .tr files with this script recognizing #actuallyUsedTag (or whatever the tag turns out to be) and handling the line specially to keep it out of the not-used-anymore section?

Seems reasonable to me.

@louisroyer
Copy link
Contributor Author

Yes, this is a scenario like that (see minetest-mods/moreblocks@86502f2#diff-673c28fb12d42fc2219aa4567e917ddb for my use case).

@Wuzzy2
Copy link
Contributor

Wuzzy2 commented Aug 16, 2023

The solution is to add a no-op function local NS = function(s) return s end at the top of your file and then mark the string literal you want to become translatable with it.

The above code could then be fixed like this:

local NS = function(s) return s end
local baseText = NS("this string should be translated")
local translatedText = S(baseText)

This works because NS just returns its argument but will be detected by the script. I have documented this my fork of the script: https://codeberg.org/Wuzzy/minetest_update_translations

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