Skip to content

Commit

Permalink
[Translate] Componentize and share Android translate infobar strings
Browse files Browse the repository at this point in the history
This CL dedupes the strings used for Chrome and WebLayer's translate
infobar implementation on Android, having both embedders use the
strings via the //components-level translate_strings.grdp.

Bug: 1101240
Change-Id: I8ba346c215338c5e1ed38b860a1469dce7f6458e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2277803
Commit-Queue: Colin Blundell <blundell@chromium.org>
Reviewed-by: Matthew Jones <mdjones@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784732}
  • Loading branch information
colinblundell authored and Commit Bot committed Jul 2, 2020
1 parent ef52e81 commit 0e8be04
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 57 deletions.
35 changes: 0 additions & 35 deletions chrome/browser/ui/android/strings/android_chrome_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -1720,41 +1720,6 @@ To change this setting, <ph name="BEGIN_LINK">&lt;resetlink&gt;</ph>reset sync<p
Update to get your language in the latest version of Chrome
</message>

<!-- TranslateInfoBar -->
<message name="IDS_TRANSLATE_INFOBAR_ERROR">
Oops. This page could not be translated.
</message>
<message name="IDS_TRANSLATE_BUTTON" desc="Possible texts to display on the translate infobar buttons. [CHAR-LIMIT=24]">
Translate
</message>
<message name="IDS_TRANSLATE_NEVER_TRANSLATE_SITE" desc="Text to display on the never translate site (like www.google.com) button. [CHAR-LIMIT=64]">
Never translate this site
</message>

<message name="IDS_TRANSLATE_OPTION_ALWAYS_TRANSLATE" desc="Option in the Chrome menu. User can click the 'Always Translate' option to indicate that they want Chrome to translate pages in this language automatically. Imperative.">
Always translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_NEVER_TRANSLATE" desc="Option in the Chrome menu. User can click the 'Never Translate' option to indicate that they never want Chrome to translate pages in this language. The variable SOURCE_LANGUAGE could be any of 50+ languages supported by Google Translate, like French, Spanish, German, Italian, Japanese, Korean, etc. Imperative.">
Never translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_MORE_LANGUAGE" desc="Option in the Chrome menu. Lets the user open a dialog to choose other target languages for translation, from a list of available languages. [CHAR-LIMIT=64]">
More languages
</message>
<message name="IDS_TRANSLATE_OPTION_NOT_SOURCE_LANGUAGE" desc="Option in the Chrome menu. Sometimes a web page's source language is not correctly identified by Google Translate, and this menu option lets the user open a submenu to select another language as the source language to translate. Phrased as a question as if to query the user, 'Is this page not in [source language identified]? If so, click here.' [CHAR-LIMIT=64]">
Page is not in <ph name="LANGUAGE">%1$s<ex>French</ex></ph>?
</message>
<message name="IDS_TRANSLATE_SNACKBAR_ALWAYS_TRANSLATE" desc="After the user selects 'Always translate pages in [LANGUAGE]', this text confirms the user's choice and lets them know that pages in [LANGUAGE] will be translated to their chosen target language automatically. Imperative. [CHAR-LIMIT=64]">
Pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph> will be translated to <ph name="TARGET_LANGUAGE">%2$s<ex>English</ex></ph> from now on
</message>
<message name="IDS_TRANSLATE_SNACKBAR_LANGUAGE_NEVER" desc="After the user selects 'Never translate pages in [LANGUAGE]', this text confirms the user's choice and lets them know that pages in [LANGUAGE] will not be translated to their chosen target language automatically. Imperative[CHAR-LIMIT=64]">
Pages in <ph name="LANGUAGE">%1$s<ex>French</ex></ph> will not be translated
</message>
<message name="IDS_TRANSLATE_SNACKBAR_SITE_NEVER" desc="Text to be displayed in translate snackbar that lets the user know this site will not be translated. [CHAR-LIMIT=64]">
This site will not be translated
</message>
<message name="IDS_TRANSLATE_SNACKBAR_CANCEL" desc="A text label on the translate snackbar widget to cancel the this selection. [CHAR-LIMIT=16]">
Cancel
</message>
<message name="IDS_MENU_TRANSLATE" desc="Menu item for triggering a page translation. The word 'Translate' should match the translation in TC ID 1613971242435858090. [CHAR-LIMIT=27]">
Translate…
</message>
Expand Down
37 changes: 37 additions & 0 deletions components/translate_strings.grdp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,43 @@
Try again
</message>

<if expr="is_android">
<message name="IDS_TRANSLATE_INFOBAR_ERROR" formatter_data="android_java">
Oops. This page could not be translated.
</message>
<message name="IDS_TRANSLATE_BUTTON" desc="Possible texts to display on the translate infobar buttons. [CHAR-LIMIT=24]" formatter_data="android_java">
Translate
</message>
<message name="IDS_TRANSLATE_NEVER_TRANSLATE_SITE" desc="Text to display on the never translate site (like www.google.com) button. [CHAR-LIMIT=64]" formatter_data="android_java">
Never translate this site
</message>

<message name="IDS_TRANSLATE_OPTION_ALWAYS_TRANSLATE" desc="Option in the overflow menu. User can click the 'Always Translate' option to indicate that they want the app to translate pages in this language automatically. Imperative." formatter_data="android_java">
Always translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_NEVER_TRANSLATE" desc="Option in the overflow menu. User can click the 'Never Translate' option to indicate that they never want the app to translate pages in this language. The variable SOURCE_LANGUAGE could be any of 50+ languages supported by Google Translate, like French, Spanish, German, Italian, Japanese, Korean, etc. Imperative." formatter_data="android_java">
Never translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_MORE_LANGUAGE" desc="Option in the overflow menu. Lets the user open a dialog to choose other target languages for translation, from a list of available languages. [CHAR-LIMIT=64]" formatter_data="android_java">
More languages
</message>
<message name="IDS_TRANSLATE_OPTION_NOT_SOURCE_LANGUAGE" desc="Option in the overflow menu. Sometimes a web page's source language is not correctly identified by Google Translate, and this menu option lets the user open a submenu to select another language as the source language to translate. Phrased as a question as if to query the user, 'Is this page not in [source language identified]? If so, click here.' [CHAR-LIMIT=64]" formatter_data="android_java">
Page is not in <ph name="LANGUAGE">%1$s<ex>French</ex></ph>?
</message>
<message name="IDS_TRANSLATE_SNACKBAR_ALWAYS_TRANSLATE" desc="After the user selects 'Always translate pages in [LANGUAGE]', this text confirms the user's choice and lets them know that pages in [LANGUAGE] will be translated to their chosen target language automatically. Imperative. [CHAR-LIMIT=64]" formatter_data="android_java">
Pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph> will be translated to <ph name="TARGET_LANGUAGE">%2$s<ex>English</ex></ph> from now on
</message>
<message name="IDS_TRANSLATE_SNACKBAR_LANGUAGE_NEVER" desc="After the user selects 'Never translate pages in [LANGUAGE]', this text confirms the user's choice and lets them know that pages in [LANGUAGE] will not be translated to their chosen target language automatically. Imperative[CHAR-LIMIT=64]" formatter_data="android_java">
Pages in <ph name="LANGUAGE">%1$s<ex>French</ex></ph> will not be translated
</message>
<message name="IDS_TRANSLATE_SNACKBAR_SITE_NEVER" desc="Text to be displayed in translate snackbar that lets the user know this site will not be translated. [CHAR-LIMIT=64]" formatter_data="android_java">
This site will not be translated
</message>
<message name="IDS_TRANSLATE_SNACKBAR_CANCEL" desc="A text label on the translate snackbar widget to cancel this selection. [CHAR-LIMIT=16]" formatter_data="android_java">
Cancel
</message>
</if>

<!-- Translate Notifications -->
<message name="IDS_TRANSLATE_NOTIFICATION_ERROR" desc="This text lets the user know that the page could not be translated.">
Oops. This page could not be translated.
Expand Down
22 changes: 0 additions & 22 deletions weblayer/browser/java/weblayer_strings.grd
Original file line number Diff line number Diff line change
Expand Up @@ -172,28 +172,6 @@
<message name="IDS_WEBLAYER_NOTIFICATION_CHANNEL_GROUP_NAME" desc="The user-facing label for the notification channel group used for notifications arising from web browsing activity.">
Web browser activity
</message>
<!-- TranslateInfoBar -->
<message name="IDS_TRANSLATE_INFOBAR_ERROR">
Oops. This page could not be translated.
</message>
<message name="IDS_TRANSLATE_BUTTON" desc="Possible texts to display on the translate infobar buttons. [CHAR-LIMIT=24]">
Translate
</message>
<message name="IDS_TRANSLATE_NEVER_TRANSLATE_SITE" desc="Text to display on the never translate site (like www.google.com) button. [CHAR-LIMIT=64]">
Never translate this site
</message>
<message name="IDS_TRANSLATE_OPTION_ALWAYS_TRANSLATE" desc="Option in the Chrome menu. User can click the 'Always Translate' option to indicate that they want Chrome to translate pages in this language automatically. Imperative.">
Always translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_NEVER_TRANSLATE" desc="Option in the Chrome menu. User can click the 'Never Translate' option to indicate that they never want Chrome to translate pages in this language. The variable SOURCE_LANGUAGE could be any of 50+ languages supported by Google Translate, like French, Spanish, German, Italian, Japanese, Korean, etc. Imperative.">
Never translate pages in <ph name="SOURCE_LANGUAGE">%1$s<ex>French</ex></ph>
</message>
<message name="IDS_TRANSLATE_OPTION_MORE_LANGUAGE" desc="Option in the Chrome menu. Lets the user open a dialog to choose other target languages for translation, from a list of available languages. [CHAR-LIMIT=64]">
More languages
</message>
<message name="IDS_TRANSLATE_OPTION_NOT_SOURCE_LANGUAGE" desc="Option in the Chrome menu. Sometimes a web page's source language is not correctly identified by Google Translate, and this menu option lets the user open a submenu to select another language as the source language to translate. Phrased as a question as if to query the user, 'Is this page not in [source language identified]? If so, click here.' [CHAR-LIMIT=64]">
Page is not in <ph name="LANGUAGE">%1$s<ex>French</ex></ph>?
</message>
</messages>
</release>
</grit>
7 changes: 7 additions & 0 deletions weblayer/grit_strings_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,12 @@ IDS_SSL_V2_RECURRENT_ERROR_PARAGRAPH
IDS_SSL_V2_TITLE
IDS_STORAGE_ACCESS_INFOBAR_TEXT
IDS_STORAGE_ACCESS_PERMISSION_FRAGMENT
IDS_TRANSLATE_INFOBAR_ERROR
IDS_TRANSLATE_BUTTON
IDS_TRANSLATE_NEVER_TRANSLATE_SITE
IDS_TRANSLATE_OPTION_ALWAYS_TRANSLATE
IDS_TRANSLATE_OPTION_NEVER_TRANSLATE
IDS_TRANSLATE_OPTION_MORE_LANGUAGE
IDS_TRANSLATE_OPTION_NOT_SOURCE_LANGUAGE
IDS_VR_INFOBAR_TEXT
IDS_VR_PERMISSION_FRAGMENT

0 comments on commit 0e8be04

Please sign in to comment.