-
Notifications
You must be signed in to change notification settings - Fork 850
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #919 from 4ian/refactor/cra2-and-jslingui
Add support for translations in GDevelop 5 🌎 For contributors, please merge master in your branches for your Pull Requests. See this comment: #919 (comment) Don't forget to remove `node_modules` folder in `newIDE/app`, and relaunch `npm install` or `yarn`, then `npm start` or `yarn start`.
- Loading branch information
Showing
255 changed files
with
33,363 additions
and
38,498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* GDevelop Core | ||
* Copyright 2008-present Florian Rival (Florian.Rival@gmail.com). All rights | ||
* reserved. This project is released under the MIT License. | ||
*/ | ||
|
||
#if defined(EMSCRIPTEN) | ||
#include <emscripten.h> | ||
#include "GDCore/String.h" | ||
|
||
namespace gd { | ||
gd::String GetTranslation(const char* str) { // TODO: Inline? | ||
const char* translatedStr = (const char*)EM_ASM_INT( | ||
{ | ||
var getTranslation = Module['getTranslation']; | ||
if (!getTranslation) { | ||
return $0; | ||
} | ||
|
||
// Uncomment lines to display a warning if the cache | ||
// for strings is not ready. | ||
// if (!ensureCache) { | ||
// console.warn('No ensureCache initialized'); | ||
// return $0; | ||
// } | ||
ensureCache.prepare(); | ||
|
||
var translatedStr = getTranslation(Pointer_stringify($0)); | ||
return ensureString(translatedStr); | ||
}, | ||
str); | ||
return gd::String(translatedStr); // TODO: Is copying necessary? | ||
} | ||
} // namespace gd | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.