-
-
Notifications
You must be signed in to change notification settings - Fork 156
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
[RFC] Translations and string parameters #131
Comments
I don't understand the problem related to using the actual variable name. That seems to be adding complication (not complexity) for the translators. What exactly is the problem you want to solve? In the linked patch, on line 416, I would use: Are you saying that gettext would turn |
If you pass '$2' it will try to find the translation of literally $2. But even if that wasn't the case, the variables get expanded before getting to gettext. I think I understand you though. Do you mean that you don't understand why use the placeholders? Well, we could use the variables themselves as placeholders (using single-quotes It'd be enough to use 2nd Edit: |
Hmmm, correct me if I'm wrong. Considering the string Passing Or should we escape P.S.: depending on the language, the position of multiple variables is likely to change. |
I guess I'm wrong. |
Yeah, I think the last one is correct. The problem is that we don't have the value for |
Oh, wait. It depends on how you're storing the first string. It could be: In the second case, $tombname would be expanded before getting to the gettext line, so we'd have Oh, that's the same as escaping the I understand what you mean by changing the position of the variables. In that case this still holds: _failure "Now the tomb ::1 tomb name:: is open at ::2 mount location::." We can have placeholders named |
But we want to expand it after gettext translation, so that it's expanded as |
That's what I want to do! 😉 This is how it goes now: _success "Now, the tomb $tombname is open."
# expands to:
_success "Now, the tomb secret.tomb is open."
# ...
msg="$(gettext -s "Now, the tomb secret.tomb is open.")"
# expands to:
msg="Now, the tomb secret.tomb is open." This is what you are suggesting (as far as I understand): _success 'Now, the tomb $tombname is open.' # doesn't expand
# ...
msg="$(gettext -s "'"Now, the tomb $tombname is open."'")"
# expands to:
msg="$(gettext -s 'Now, the tomb is open.')" # note the double space -- $tombname has no value here
# which expands to:
msg="Now, the tomb is open." This is what I suggest: _success "Now, the ::1 tomb name:: is open." $tombname # doesn't expand
# ...
msg_tmp="$(gettext -s "Now, the ::1 tomb name:: is open.")"
# which expands to:
msg_tmp="Ahora la tumba ::1 tomb name:: está abierta."
# ...
msg="$(ninja_zsh_substitution "Ahora la tumba ::1 tomb name:: está abierta.")"
# which expands to:
msg="Ahora la tumba secret.tomb está abierta." |
Interesting analysis. I remember being puzzled by these issues in the past and giving up. I like gdrooid solution and I am in favour of it. Only question is why delimiters of 2 chars? :: might be confusing, why not %varname% ? |
What about escaping |
@jaromil I used two chars to differentiate it from the normal use of the char in a string. One might want to use Also note that
@hellekin With backlash we'd get the same effect as with the single quotes, except that we'd have to force it to expand, but again, there'd be no value for |
OK. I understood why backslash is not enough. Tricky issue. I want to go for your solution, but that will be a lot of work since you will have to change also current translations. If you like to make it simplier, I would also go without the "possible comment inside ::" but just a number, since I think the strings are rather clear without the variable name already. But then if you manage to put it in there, is more work, but is nicer. Either way, when you can do this pull request I will merge it, so please go ahead. I'd rather appoint you in charge for the internationalization of Tomb, since you have shown very good understanding of the problems related. |
👍 I'll probably make a PR on Wednesday. Tomorrow is my last day in the US and then I have to make a long trip back to Europe, so I'll probably start coding while in flight. I'll gladly take that charge, but then I'd like to talk on IRC or XMPP (gdrooid@dukgo.com) first if we can agree on a date/time (after I come back to Europe). |
on it :D On 16/09/14 19:13, Dani wrote:
|
Right now tomb translations DON'T work as I intended when I pushed #123. Back then I didn't realize that parameter expansion would mess with gettext, and thus, I took for granted that it would work on every string... I was wrong.
To make translations work as intended I propose the following: take
$variables
out of the strings and use::placeholders
instead, which can be substituted after going throughgettext
. For example:That means that translators would face
::n
placeholders, instead of variables with sensible names. To help them we could add comments (the name of the variable, or even more sensible sentences) to the placeholders:Let me know what you think please. I want everybody's thumbs-up before I proceed, because although the zsh code is pretty simple, there's some work to be done on the .pot and .po files, plus in all the tomb strings, to adapt to this new model.
Suggestions for other symbols or formats for the placeholders and comments are welcome, this is not definitive. For example, I like:
The text was updated successfully, but these errors were encountered: