注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

写着玩

Bob

 
 
 

日志

 
 
 
 

UI Localization  

2010-01-10 22:22:04|  分类: Chrome |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
How to add a string
  1. Add the string to the grd file (generated_resources.grd, webkit_strings.grd, chromium_strings.grd or google_chrome_strings.grd).  See below in the "Overview of files" section for guidence on which file to add the string to.
  2. The next time you build the solution, this will automatically add the en-US string to en-US.dll.
  3. In your code, include chrome/common/l10n_util.h and generated_resources.h.
  4. To get the string, use l10n_util::GetString.  Alternately, you can use l10n_util::GetStringF which will replace placeholders $1 through $4 with the extra arguments of GetStringF.
If you are contributing code to the Google Chrome version of Chromium, then this is all you need to do.  The process of translating the string from en-US to the other languages will be handled by Google's translation team.

If you are adding a string to Chromium that you want for a different version of Chromium and you want to have translation in other languages, you need to add translations to the .xtb files in /src/chrome/app/resources.  These files are have a transalation id that is based on a hash of the en-US string (see /src/tools/grit/external/FP.py for details on the hash).


Overview of files


/src/chrome/app/generated_resources.grd
/src/webkit/glue/webkit_strings.grd
  Strings for the main UI language (en-US) get added to these files.  If the string is used in webkit (i.e., shows up in content), then add the string to webkit_strings.grd.  Otherwise, add the string to generated_resources.grd.  These grd files are the "pivot" format that everything else is based.

/src/chrome/app/resources/*.xtb
/src/webkit/glue/resources/*.xtb
  These files contain translations in each language of the en-US strings in the grd files.

/src/tools/grit/
  GRIT (Google Resource and Internationalization Tool) is a script that that runs during the build that combines the grd files with the xtb files to generate a C++ header file with string IDs and a Windows resource file (.rc) containing the strings.

/src/chrome/app/chromium_strings.grd
/src/chrome/app/google_chrome_strings.grd
  Similar to the generated_resources.grd and webkit_strings.grd but these files allow for having strings that refer to Google Chrome vs Chromium.  These files should define strings for the same IDs, they just have different translations.  Visual Studio will build the correct file based on an environment variable.

/src/chrome/app/resources/locale_settings.grd
  This file contains values that vary by locale, but are not sent to translators (i.e., they are used by developers).  For example, the default font size depends on locale, so we put it in this file.  We put the en-US value in locale_settings.grd and for all other locales, we put values in the locale_settings*.xtb files.  You must provide a value for all locales for the grd file to build properly.


Workflow for how strings get translated for Google Chrome
  1. String gets added to a grd file
  2. Translators are provided with the new grd files
  3. Translations are created and new xtb files are generated
  4. The new xtb files are checked into the Chromium source tree
  评论这张
 
阅读(441)| 评论(0)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017