using gettext

using gettext

by Jurgis Pralgauskis -
Number of replies: 6
Hello, I am trying to figure out, how to use PHP gettext + poEdit
yes google proposes many answers like this and this
but I'd have to make some greps/regexps to add _("blah blah") instead of "blah blah".

I see the opportunity to have less work when translating similar things in the future, as gettext  remembers translation of phrases and can propose them automatically (marked as fuzzy) (or is it poEdit, whitch does it, doesn't matter now)

well, but as I understand gettext acts in a specific manner:
it translates things not in your applications language files, but on the fly - when program runs. Am I right?
If yes, then how could I adapt it ?
I'm just wondering if smb could give some proposals?
would be fankful for some 7-step instruction, if smb has it by hand smile
or would it be better to post it in general dev forum??

fanx in adwance smile
Average of ratings: -
In reply to Jurgis Pralgauskis

Re: using gettext

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Moodle doesn't need to use gettext - our mechanism is more flexible.  smile
In reply to Martin Dougiamas

Re: using gettext

by Jurgis Pralgauskis -
well, but I am kind of lazy of typing same words each time (so "quiz" is repeating over and over smile).
I could copy/paste, but probably I'd chose replace all better (via some text ed), because toggling between text boxes also takes time.
As I imagine, poEdit would translate "quiz" or "quiz type" or similar for me and check it "fuzzy" (or may be poEdit doesn't translate parts of phrases?? I still haven't tried it).
And some interface stuff is the same as in other portal systems, so I'd have some preparations for localising other OS smile.  And even in moodle some phrases repeat from module to module.

fanx for Your patience explaining me why moodle interface is more flexible ?..
In reply to Martin Dougiamas

Re: using gettext

by János Fehér -
It's OK, but there are several tool to help the translators. For Moodle, we now have only an editor. We cannot merge the English files with a click, we cannot separate the translated sentences and so on. It would be nice if we could use tools to translate Moodle. There're too many sentences to do it easy with only an editor.
In reply to Martin Dougiamas

Re: using gettext

by Cristi Magherusan -
Hello,

@Martin: Could you please explain why do you think this approach is more flexible than gettext?

For example, say I'm trying to translate it(~9000 strings) to a new language in a more distributed manner, like helped by a few dozens students which can help me finish the translation in no time, by doing it as their homework.

With gettext we can just use external tools like launchpad's translation feature and we could get it done a lot faster, and in the same time to see what each student did, so they could get some grades for it.

As far as I know, currently moodle's translation feature needs that the translators have admin rights on the moodle site.

I wouldn't like that my students have admin permissions on my site, so I find this as a stopper issue, and the gettext way seems much more flexible, not to mention that this has become the standard way of doing it and almost anyone uses gettext nowadays for locale stuff on non-trivial projects.

Can anyone estimate how consistent would be the effort of converting moodle to gettext? Maybe this could be somehow automated. What do you think?

Best regards,
Cristi
In reply to Cristi Magherusan

Re: using gettext

by Nicolas Martignoni -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

You could use an installation of Moodle just for your translation needs, adapting a role permitting the use of the translation UI.

In reply to Cristi Magherusan

Re: using gettext

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
The effort will be huge, unless you can somehow change the inner workings of Moodle's get_string function to use gettext internally without any other part of the code being aware of the fact. I don't know enough about gettext to comment on that.

Actually, it seems that you don't want Moodle to use gettext for its string handing. You just want to be able to use gettext's associated translation tools. That opens up another possibility: Could you write a script that converts moodle language files to gettext format files and back again. If so, you can use gettext's tools to do the translation without having to change Moodle.