-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Today widget localization #15614
Today widget localization #15614
Conversation
You can trigger optional UI/connected tests for these changes by visiting CircleCI here. |
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.
Works as described!
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.
Hey @Gio2018!
Thanks for the ping about this. I discussed with @AliSoftware this morning and we have one suggestion – currently, the keys here share names with similar keys in the main app. Because widgets have different considerations (as a for-instance, we may need to use a very compact string in non-English languages in order for them to fit), we think it would be worth namespacing the keys in order to avoid collisions between strings in the main app. This would be an excellent case for using synthetic key names (such as TODAY_WIDGET_COMMENTS_LABEL
– then providing context such as "this will appear in a widget so should be represented by a concise translation" in the translation notes).
In terms of updating these, for now this will likely be a manual process (ie – we'll ingest the widget base localization into GlotPress, but copying the translations back into the widget will have to happen by hand for now). We're working on automation for this, but it's unlikely to ship before this needs to land.
Hope that helps – happy to discuss further!!
You can trigger an installable build for these changes by visiting CircleCI here. |
…lue if localization is missing, TodayWidgetView
Hey @Gio2018 , sorry to come late to the party. To complement what Jeremy said above, specifically on the use of synthetic key names:
I'll let you re-update the keys with the new convention, and I'm hoping that for potential future changes in the copies we won't forget to do manual updates… be sure to keep us in the loop if that happens. |
I like the reverse DNS suggestion. The only question in my mind is if we need to namespace it further adding what app the widget belongs to.
I think this will depend on whether we're using our WPiOS GlotPress project for other Apps too (which I don't know), or just for WPiOS. My 2 cents. |
Good thinking; but we do use separate GlotPress projects for the other apps, so it's unnecessary to namespace the key with the app name 🙂 For your info: we do use a single GP project for all targets of a given app (main app target, widgets, libs and dependencies…) and merge all of the That way translators of a given app don't need to go into different GP projects to translate various parts of the app (and don't need to know about the technical details of which lib/target the string comes from) and only deal with a single GP project for a given app. This is alsy why we want to namespace the key names by target (widget vs app), to avoid conflicts when we merge strings from different targets in the unique "WordPress iOS" GlotPress project. But that merging is only per-product / per-app. Each apps still have its own, separated GlotPress project, so there's not risk a key in WordPress-iOS could conflict with WooCommerce-iOS for example. |
… in iOS 14 today widget
…onfigured view title
Thanks @jkmassel @AliSoftware @diegoreymendez for the reviews. I updated the keys and added the unconfigured view title (which will need to be translated). |
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 tested this using en-CA
and fr
as the languages. In both cases because it was already translated, the strings showed up as expected.
To test the default case, I deleted the en-CA
and fr
localizations for the widget and re-ran the app. The strings appeared correctly using the default values.
I took a look at the LocalizedStringKey
extension and it's nice and straightforward. I've left a couple of nitpicks for your consideration, but they're not required!
extension LocalizedStringKey { | ||
static let defaultBundle = Bundle(for: HomeWidgetTodayRemoteService.self) | ||
|
||
/// TODO - TODAYWIDGET - LocalizedStringKey is used as a wrapper of NSLocalizedString, in order to use synthetic keys and assign a default value |
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 might not be worth mentioning this as a TODO
just because IMHO it's unlikely to change any time soon. It seems like this was a great (missed) opportunity for Apple to clean this up and have LocalizedStringKey
have proper fallback behaviour and they didn't, so I wouldn't expect this to change.
I like the comment though explaining why it exists and the circumstances under which it could be replaced. Just not sure if TODO
is that useful since it might be in that state for a looooooong time 😄
@@ -0,0 +1,12 @@ | |||
import SwiftUI | |||
|
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.
Is two spaces between import
statements and the extension definition typical?
@@ -0,0 +1,17 @@ | |||
/* Title of comments label in today widget */ | |||
"widget.today.comments.label" = "Comments"; |
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 reverse-DNS notation is much better than the ALL CAPS for sure!!
Fixes #15157
Note:
To achieve this, I copied the existing Today Widget
Localizable.strings
. Since this did not contain the "Today" string, I retrieved this from the main app, but since it was a manual process, translations will need to be verified. Also, we need to add translations of the placeholder/unconfigured view, that are not present at the moment.To test:
PR submission checklist:
RELEASE-NOTES.txt
if necessary.