Translations
This page explains how to translate Bromite-specific text introduced/modified by patches.
To translate a string we need to know:
- text to translate
- translation id
- locale file (
.grd
extension)
First identify where the text to translate is coming from; for example the Exit
string is added by Add-exit-menu-item.patch.
We should find all new added strings from the grd(p) files and translate them to your locale.
Exit
-> 退出
The grit tool is necessary. Translation ids can be generated using following command:
python -c 'from grit.extern import tclib;print(tclib.GenerateMessageId("Exit"))'
9148058034647219655
This means that Exit
corresponds to a translation ID of 9148058034647219655
.
If you have checked-out the Chromium source code you can use the local version by prepending a declaration of PYTHONPATH=$PWD/tools/grit
Usually a locale file can be found in the subdirectory of the .grd(p)
files. In this case, the grd file is located at chrome/browser/ui/android/strings/android_chrome_strings.grd
. And the locale file is located at chrome/browser/ui/android/strings/translations/android_chrome_strings_zh-CN.xtb
Now we can append our translation to the file and create a patch for it.
diff --git a/chrome/browser/ui/android/strings/translations/android_chrome_strings_zh-CN.xtb b/chrome/browser/ui/android/strings/translations/android_chrome_strings_zh-CN.xtb
index 8b4ba9c..edf495d 100644
--- a/chrome/browser/ui/android/strings/translations/android_chrome_strings_zh-CN.xtb
+++ b/chrome/browser/ui/android/strings/translations/android_chrome_strings_zh-CN.xtb
@@ -1264,4 +1264,5 @@
<translation id="983192555821071799">关闭所有标签页</translation>
<translation id="987264212798334818">常规</translation>
<translation id="996149300115483134">动态卡片上的菜单已关闭</translation>
-</translationbundle>
\ No newline at end of file
+<translation id="9148058034647219655">退出</translation>
+</translationbundle>