-
Notifications
You must be signed in to change notification settings - Fork 827
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
Translation and formatting expressions #319
Translation and formatting expressions #319
Conversation
That's a pretty big project you have there :) Let's try to keep things simple, in particular for the Javascript engines where the translations could be a "simple" JSON file. In most cases, JS games will run in an environment (browser, Cocos2d-JS, Electron sometimes) that do not provide access to external files (browser in particular), so the translations will have to be built in. |
If we explicitly allow adding other files to the "image" bank. Then, we can easily add builtin .mo files to projects, solving the problem for Javascript projects. Then, I chose the gettext format so that we don't have to bother with the translation editing tool as there are many already developped. |
.mo files are in a binary format so I'm not totally sure we can use it in Javascript (in Node.js there are surely ways to do it, but not in "Vanilla JS" in browsers). But some people already created workaround it seems: https://github.com/mikeedwards/po2json |
Sure it's a good idea to stick to existing formats :) |
If we allow to embed the .mo files (either by putting them in the image manager or, like the sound, by automatically put them into the compiled project), we can load them using the ResourcesLoader from pixi or cc.Loader from Cocos2D. Then, we can get a byte array and I can, as I made for the C++ implementation, write a simple parser for the .mo file. |
Add support for variadic arguments in instructions and expressions (Currently, not supported by the editors, but can be set manually for expressions)
…y return the string it gets)
…t the translations
As they are already escaped in GDevelop's expressions
158f3b6
to
c9374cc
Compare
Add rawfile parameter type allowing the user to select a file with custom filters (as extra info)
How can I get the file in a synchronous way without forcing it from being preloaded? (and is there a way to preload a file without asking the user to add the file to the "image bank"?) |
What is the issue with the |
The problem is how to preload the file during the loading of the game. Do I
need to create à "translation **file** manager" that uses PIXI.Loader like
the textures and the sounds managers ?
Le mar. 27 déc. 2016 15:41, Florian Rival <notifications@github.com> a
écrit :
… What is the issue with the rawfile parameter that you've added. What is
your problem precisely?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#319 (comment)>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AA63oNY3Ef02h2ai8Jg5CwNDdPjuPunyks5rMSONgaJpZM4K-Gc_>
.
|
Native game only implementation
Do not merge now, opened for discussions.
This PR adds two features.
The features
String formatting
A string expression provides a string formatting feature with a simple and easier syntax than the C syntax.
For example:
I implemented a small parser for this syntax, tell me how I can improve/optimize it. It uses
std::string
internally to avoid unnecessary UTF8 iterating as the only relevant characters are {, } and the numbers.
To make this string expression possible, I added a new type to the parameters: ````variadic```. The kind of parameter obviously only works if placed at the end of an expression/action/condition parameters list. The extraInfo field is used to determine the type of the variadic parameter (only one type, either "string" or "expression", so this is more limited than the C++ parameters packs).
These parameters accepts from 0 to an infinity of values. The editors have not been updated to allow assisted insertion of such parameters making them impossible to use currently in conditions and actions. However, the expression parser has been updated not to throw error messages due to the parameter count with variadics.
Translation
Using the
_("something here")
string expression, strings can be translated. A button has been added to the "Project" ribbon to generate a .pot file from all marked strings and an action is provided to load a translation from a .mo file.The .mo parsing is done with a simple "parser" I wrote too.
Here is the documentation draft of the translation feature: http://wiki.compilgames.net/doku.php/gdevelop/documentation/game_translation
Discussion
Some points I would like to discuss: