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

Add support for translations in GDevelop 5 🌎 #919

Merged
merged 23 commits into from
Feb 16, 2019

Conversation

4ian
Copy link
Owner

@4ian 4ian commented Feb 2, 2019

  • Update to create-react-app v2.
  • Install js-lingui and remove react-i18next
  • Fix Flow errors with js-lingui see fix: flow typing of React API with Flow 0.92 lingui/js-lingui#448
  • Extract translations into PO catalogs for
    • editor
    • JS extensions
    • GDCore/GDCpp/GDJS/C++ extensions
  • Script to combine all translations (PO files for the editor + the rest) and compile them.
  • Edit README to explain what script to launch to extract/compile translations.
  • Remove hardcoded "fr" language used for test.
  • Add language dropdown in preferences.
    • Potentially show the translation percentage? (or add "beta" or translations that have a small completion).
    • Ensure that when language is chosen, JS extensions are reloaded and builtin extensions too. Or relaunch GD?
  • Add a menu item to help discover the languages.
    • Potentially display the language on the start page to help people discover that the language can be changed.
    • In the future, the language can be asked at the first launch.

Things that will need to have translations markers added - this can be done progressively after this PR is merged:

  • Extensions are ok, already have t("...") (that I updated to _("..."))
  • GDCore/GDCpp/GDJS/C++ extensions (already using _("..."))
  • All components in the new editor will need to use <Trans> (or withI18n + this.props.i18n._(...) like done in MainFrame.js)
    • Fix the const t = str => str; //TODO
  • label props
  • emptyExplanationMessage
  • emptyExplanationMessage
  • emptyExplanationSecondMessage
  • Fix the unsafe-eval.

@4ian 4ian force-pushed the refactor/cra2-and-jslingui branch 4 times, most recently from 432b599 to 9cf2fbb Compare February 4, 2019 22:54
@Wend1go
Copy link
Contributor

Wend1go commented Feb 5, 2019

Is it already possible to add translations for the new features in GD5 that were not available in GD4?

@4ian
Copy link
Owner Author

4ian commented Feb 5, 2019

Not quite, extracting translations and uploading them to Crowdin is part of what is achieved in this Pull Request.

Strings to translate in the editor will have to be put between a <Trans> component so that they are extracted.
Strings to translate in the extensions will be extracted when put between a the function call t("blabla") (which will be renamed with an underscore _("blabla") so that the translations can be extracted with the same tools as the C++ codebase).

Extensions are ok because from the start I introduced the "t" function. The editor will need more work because I need to go through every string and mark them as translatable.

@4ian 4ian force-pushed the refactor/cra2-and-jslingui branch 3 times, most recently from 9b4b9a4 to 058b350 Compare February 5, 2019 22:56
@4ian
Copy link
Owner Author

4ian commented Feb 6, 2019

Made a script that added translation markers to most strings of the editor :) Still have quite a bunch to go manually through, made another script to list them.

Will merge this when Flow is fixed in js-lingui. As there are a lot of changes, better merge this as soon as possible.

@4ian
Copy link
Owner Author

4ian commented Feb 6, 2019

Might actually host a built version of js-lingui so that we can go ahead and merge this asap, and start having translations, while I finish to add missing translation markers.

@4ian 4ian force-pushed the refactor/cra2-and-jslingui branch from c9643c2 to 2547a8b Compare February 7, 2019 00:06
@4ian 4ian force-pushed the refactor/cra2-and-jslingui branch from 48037cb to 4323000 Compare February 9, 2019 14:08
@4ian
Copy link
Owner Author

4ian commented Feb 16, 2019

This Pull Request is becoming really super large and is going to need more and more work if we merge other Pull Requests. I'll merge it now, and will work on improving the remaining points in the description (missing translations markers, relaunch the app or reload translations when a new language is chosen).

@blurymind @Bouh @Wend1go @Lizard-13 or anyone that might have some Pull Request or using GD development version.

  • When this is merged in master, I recommend merging master in your development branches.

  • You'll potentially have conflicts, because my changes were quite large spread and consisted in adding <Trans>blabla</Trans> components, and/or i18n._(tblabla) (for translations of raw strings). If you should be able to apply the proper changes. In case of doubt, ask me.

  • In extensions, I've renamed the t function (used to translate strings: t("blabla")), to _ (_("blabla")). If you're making a new extension, you can keep t, but at some point I'll have to rename all call to t to _. Calling the function t or _ does not change anything code wise, it's for the translator extractor to work that extension (JsExtension.js files) must use _.

  • Remove libGD.js in newIDE/app/public. (it will be redownloaded)

  • Lastly, once you have merged master in your branches and solved conflicts, you must relaunch npm install or yarn (and then npm start or yarn start). Failing to do so will make GDevelop unable to launch itself. In case of doubt, erase the folder called node_modules in newIDE/app and then launch you must relaunch npm install or yarn.

Don't forget npm install or yarn! :)

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 this pull request may close these issues.

2 participants