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

gettext.extract --merge does not preserve default msgstr's #55

Closed
chrismccord opened this issue Nov 20, 2015 · 15 comments · Fixed by #56
Closed

gettext.extract --merge does not preserve default msgstr's #55

chrismccord opened this issue Nov 20, 2015 · 15 comments · Fixed by #56

Comments

@chrismccord
Copy link
Contributor

I may be missing something, but when running mix gettext.extract --merge for the first time, I find all the message strings are blank. This results in all templates returning blank strings until I go fill in the translations. It seems like a better approach would be to have the msgid copied over to the msgstr. Thoughts?

Example of generated .po

#: web/views/page_view.ex:3
msgid "A productive web framework that does not compromise speed and maintainability."
msgstr ""

#: web/views/layout_view.ex:19
msgid "Get Started"
msgstr ""

Example of what I'd like to be generated:

#: web/views/page_view.ex:3
msgid "A productive web framework that does not compromise speed and maintainability."
msgstr "A productive web framework that does not compromise speed and maintainability."

#: web/views/layout_view.ex:19
msgid "Get Started"
msgstr "Get Started"
@josevalim
Copy link
Contributor

The question is: do we want to automatically copy it for all idioms? Or just for english? And which one is a better default even for other languages, showing no text or showing the text in english?

It feels copying msgstr for the merge is indeed the best way to go.

@chrismccord
Copy link
Contributor Author

I was thinking only for English, otherwise you'll have stray english fragments to track down when you make changes

@josevalim
Copy link
Contributor

@chrismccord right. assuming you don't track those down, the website/app will show no text, which I think is worse even for non-english languages?

@whatyouhide
Copy link
Contributor

The idea would be to turn a .pot (with blank strings) into a .po only when you're ready to translate all of the strings in the language of the new .po.

@josevalim / @chrismccord Do you think people would use "" as a translation on purpose for some reason? If not, we could just make gettext see "" as untranslated strings, so that when it encounters one, it just returns the msgid. (I think I already proposed this a long time ago but we didn't think about it too much because it was a bit early in the life of gettext)

@bryanenders
Copy link

I like what @whatyouhide is proposing. It prevents the case of showing no text where no translation is yet provided, making it easy for a programmer to internationalize up front and defer localization. It also yields a translation file that a translator can more easily and intuitively complete (i.e., they don’t have to delete text or hunt for where they left off). It also facilitates piecemeal translation: it’s clear where translations are missing in the .po, those strings are empty.

@bryanenders
Copy link

Also, the tools for working with .po files expect that a blank msgstr is awaiting translation (not one whose text matches its msgid). The portable object format and its generation is pretty clearly defined. The parsing of those files is not. That’s where we can define new behaviour, such as translating msgstr "" to its msgid.

@whatyouhide
Copy link
Contributor

@endersstocker the parsing may not be clearly defined, but I wouldn't do things like msgstr :empty or turning msgstr "" into msgstr MSGID_HERE in the parser (a lot of tools support reading/writing PO files and I want to mess them up as little as possible).

What I was proposing was doing this at a higher level, in the l(n)gettext functions: when we try to find a translation for "foo" in locale "loc" but get back "", then we fallback to the value of the msgid.

@bryanenders
Copy link

@whatyouhide I’m with you. I meant parsing in a broader sense. I’m saying keep the .po generation the way it is; change how gettext handles an entry with msgstr "".

@josevalim
Copy link
Contributor

@whatyouhide just so I understand, do tools like poedit use things like msgstr "" to identify what needs to be translated? Couldn't use a comment for that (like we do with # fuzzy?

At first, replacing "" makes me feel a bit uncomfortable. But if we don't have another option, then we don't have another option. :)

@whatyouhide
Copy link
Contributor

@josevalim I'm not sure but when you take a .pot file and create a new .po file from that file using poedit, msgstrs are empty (""), so I guess this is the correct behaviour? I can't find a "filter" option in poedit to show what needs to be translated but when you make poedit check for problems with translations, it reports this:

screen shot 2015-11-21 at 16 20 45

The translations that it reports as "not translated yet" are just translations with empty msgstr.

@josevalim
Copy link
Contributor

@whatyouhide so we should do it on our gettext side, you are right. If we have an empty string, we should show msgid.

@whatyouhide
Copy link
Contributor

@josevalim yep. Should we warn somewhere for this kind of things? Something akin to ".po file for locale pt_BR exists but this translation is empty"?

@josevalim
Copy link
Contributor

If we are going to warn, then we need a way to copy the msgid to msgstr, at least for english based locales. Otherwise, I would go with no warning.

@whatyouhide
Copy link
Contributor

Ok, #56 got merged so now the behaviour for translations with empty msgstr is to just default to the msgsid. (for plural translation, "empty msgstr" means one or more empty msgstrs)

@chrismccord
Copy link
Contributor Author

😻

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

Successfully merging a pull request may close this issue.

4 participants