-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use gutenberg translation files locally #536
Conversation
'tr', // Turkish | ||
'zh-cn', // Chinese (China) | ||
'zh-tw', // Chinese (Taiwan) | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, can we add el
too? I'm biased :P
src/app/App.js
Outdated
@@ -1,31 +1,63 @@ | |||
/** @flow | |||
* @format */ | |||
|
|||
import '../globals'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to import globals
here too? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't be required, removing it 👍
src/app/App.js
Outdated
}; | ||
setLocale( locale: ?string ) { | ||
const translationsFromParentApp = this.props.translations || {}; | ||
const translations = Object.assign( {}, translationsFromParentApp, getTranslation( locale ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I'm thinking, how about giving the WP apps priority here? Like, if there's a conflict between what the parent sends and what Gutenberg has then let's give the parent priority. That would also give us the ability to have each mobile platform decide to overwrite a string, for whatever reason (e.g. platform guidelines). WDYT?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds sane. The only thing I'm afraid of though is mixing english and an other language in the case of using a language which is supported by the app but not by gutenberg for instance.
If you don't think it's a problem I can give the parent app priority
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, won't that be true the other way too? Like, if some strings are translated by GB but the native specific ones are not, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I went with your approach in the end and decided to mix both and give priority to the parent app 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All in all, I think that giving priority to the native side strings should be a good start. We can revise if we see it be problematic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I checked the current Spanish translations in both apps and Gutenberg for common strings, and everything seems pretty consistent. The only difference I've spotted that's perhaps relevant is how media library is translated, and it makes sense that we're consistent with the app translation, so good call 😁
hey @etoledom 👋 it'd be ok if you just review the iOS bridge and iOS example app changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The iOS part looks good on the example app! ✅
@@ -116,6 +116,15 @@ extension GutenbergViewController: GutenbergBridgeDelegate { | |||
} | |||
|
|||
extension GutenbergViewController: GutenbergBridgeDataSource { | |||
|
|||
func gutenbergLocale() -> String? { | |||
return "en" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could send the device locale directly. Since is the example app is not a blocker, but it would nice to test translations just by changing the device language in the run settings for fast tests.
return "en" | |
return Locale.preferredLanguages.first ?? "en" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
When I run
Is that expected? |
We merged wordpress-mobile/gutenberg-mobile#536 and recreated the bundles
I was mentioning this to Tug on slack, that Norwegian seems to be on Glotpress so maybe this is more of a WordPress.com think. It might be a good idea to switch to fetching from glotpress directly before the release. This seems to download translations but I haven't tested if it's the same JSON format:
|
Addresses part of #203
Requires wordpress-mobile/WordPress-Android#9249
Requires wordpress-mobile/WordPress-iOS#11056
Requires those 2 PRs to be merged first so the gb-mobile strings get translated in WPiOS and WPAndroid glotpress:wordpress-mobile/WordPress-iOS#10999
wordpress-mobile/WordPress-Android#9214
Summary
This PR adds a local script that downloads gutenberg translation files and cache them locally.
Testing Instructions
Load this branch locally
Run
yarn start
and check that translation files are downloaded ini18n-cache/data
and that a file is generated ati18n-cache/index.native.js
Edit
src/app/App.js
and replacesetLocaleData( getTranslation( locale ) );
withsetLocaleData( getTranslation( 'es' ) );
Reload the app and check that parts of the app have been translated to Spanish
Reset the code and run
yarn wpandroid
oryarn ios
Change the app or the phone language
Check that gutenberg editor is translated
A PR in both https://github.com/wordpress-mobile/WordPress-iOS and https://github.com/wordpress-mobile/WordPress-Android will be necessary to pass the new
locale
parameter.