Gettext Localisation for CEF applications?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Gettext Localisation for CEF applications?

Postby WrinklyNinja » Thu Sep 04, 2014 3:42 pm

Hi,

I'm developing an application using CEF to render its UI, and I've been unable to find any localisation libraries up to the task of localising CEF-based applications. This is a bit of a sticking point, because the previous wxWidgets-based version of the application has been localised into 8 languages other than English, and I'd quite like to see support for those localisations continue.

I'm looking to use a gettext-based localisation solution, because that's what the application has used in the past, and what the translators are comfortable with (and I see no reason to change). I've also got to ship .mo files because the C++ side of the application generates some strings that need localisation. Given that, I'm looking for a browser-Javascript .mo file parser that can output Jed-compatible data, because Jed (https://github.com/slexaxton/Jed/) has the best interface of the Javascript l10n options I've found. However, I can't find anything of the sort, and I'm now looking to

1. Roll my own browser-JavaScript .mo file parser. There's gettext-parser for Node.js, which I could adapt code from.
2. Ship .po files in addition to the .mo files, and use Pomo (https://github.com/cfv1984/Pomo) to parse them, then adapt them for Jed myself. Pomo doesn't look like it's particularly well adopted though, so I'd rather adapt gettext-parser.

I've got a couple of questions for the forum:

1. What does everyone else use for l10n?
2. Has anyone heard of anything I could use to save myself having to write more new code?
WrinklyNinja
Newbie
 
Posts: 3
Joined: Thu Sep 04, 2014 3:30 pm

Re: Gettext Localisation for CEF applications?

Postby magreenblatt » Thu Sep 04, 2014 6:59 pm

I don't have an existing solution to suggest, but you might want to consider a single design that provides localized strings to both JS and C++. For example you could use JSON files for the localizations and then either (a) parse those files from both C++ and JS or (b) parse the files in one language and expose bindings (API) to the other language. Also, depending on how your app is designed (whether you bundle everything with the executable or have a dynamic update mechanism), this might simplify the process of supporting new languages in the future.
magreenblatt
Site Admin
 
Posts: 12407
Joined: Fri May 29, 2009 6:57 pm

Re: Gettext Localisation for CEF applications?

Postby WrinklyNinja » Fri Sep 05, 2014 7:02 am

magreenblatt wrote:I don't have an existing solution to suggest, but you might want to consider a single design that provides localized strings to both JS and C++. For example you could use JSON files for the localizations and then either (a) parse those files from both C++ and JS or (b) parse the files in one language and expose bindings (API) to the other language. Also, depending on how your app is designed (whether you bundle everything with the executable or have a dynamic update mechanism), this might simplify the process of supporting new languages in the future.


That's sort of what I'm after, but with .mo files instead of JSON files (because that's the de-facto standard). I've chosen option (a) there: I want to parse the .mo files in C++ and JS, but there's no non-Node.js parser for .mo files that I can find.

As for option (b), I suppose having a JS translate() that sends a CefQuery to do the actual translation on the C++ side and send back the translated string is a possibility. It's not something I'd considered. The downside would be that I'd basically be reimplementing Jed's API with a different backend in JS, and then an equivalent query API on the C++ side, if I wanted to have good gettext support.

As for adding new languages, it's not really an issue. A new language does require ~6 lines of code changes, but I only ever release full bundles, so rebuilding the executable isn't a problem.

After more thought, it's still looking like a browser JS parser for .mo files that outputs Jed-compatible data is the better option.
WrinklyNinja
Newbie
 
Posts: 3
Joined: Thu Sep 04, 2014 3:30 pm

Re: Gettext Localisation for CEF applications?

Postby WrinklyNinja » Tue Sep 09, 2014 3:21 pm

Well, for what it's worth, I ended up writing a library to solve my problem: Jed Gettext Parser is what it sounds like. It only does MO file parsing right now, but I'm open to the possibility of including PO file parsing at some point in the future.
WrinklyNinja
Newbie
 
Posts: 3
Joined: Thu Sep 04, 2014 3:30 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 19 guests