For anyone working on the UI and using VS Code, you can create a user Snippet and keyboard shortcut so that you can easily add the localization code when needed. Add the user Snippet to VS Code by going to File->Preferences->User Snippets and pasting the code below in the javascript.json file.
    "AddLocalizedString": {

"prefix": "loc",

"body": [

"{this.props.translate('${1:stringKey}')}$0"

],

"description": "Add placeholder for localized string. Replace stringKey with localized string key."

}

To use your snippet you would type loc to insert this line in your code:    {this.props.translate('stringKey')}

then replace the stringKey text with the key of the localized string found in the en.js language file.

For example:

{this.props.translate('stringKey')} for the string 'Schedule' becomes {this.props.translate('scheduleString')}

You can also add a keyboard shortcut by going to File->Preferences->Keyboard Shortcuts and then clicking the link at the top to keybindings.json. Add the following to the keybindings.json file:

{

"key": "ctrl+l ctrl+l",

"command": "editor.action.insertSnippet",

"when": "editorTextFocus",

"args": {

"langId": "javascript",

"name": "AddLocalizedString"

}

}

When you enter ctrl+l twice, the code for localizing a string will be inserted. You can change the "key" in the shortcut above to whatever combination works for you.

最新文章

  1. C#--图片上传(PC端和APP)保存及 跨域上传说明
  2. C/C++程序编译流程(预处理->编译->汇编->链接)
  3. ED/EP简介
  4. 剑指OFFER之顺时针打印矩阵(九度OJ1391)
  5. WPF 进度条
  6. ORA-01652 错误中报出的不是Temp表空间的情况。
  7. Shader程序中内置的状态变量
  8. JAVA 计算地球上任意两点(经纬度)距离
  9. .NET PageAdmin CMS
  10. js几种基本数据类型及之间转换与java的不同、js数组一些常见操作
  11. flume 1.7在windows下的安装与测试
  12. [译]ASP.NET Core 2.0 本地文件操作
  13. FastDFS教程IV-文件服务器集群搭建
  14. rpm 相关问题
  15. Vue 2.0 路由全局守卫
  16. 华为AR-111S路由器GRE协议设置
  17. C#控制键盘按键(大小写按键等)的代码
  18. flask_SQLALchemy之多表查询
  19. 如何安装psutil以及提示缺少python.h头文件
  20. Python 项目实践二(生成数据)第二篇

热门文章

  1. Android Studio中出现Gradle's dependency cache may be corrupt错误的解决办法
  2. HDU1116(欧拉路径+并查集)
  3. python字符串的格式化
  4. InnoDB INFORMATION_SCHEMA System Tables
  5. ASP.NET MVC中如何在客户端进行必要的判断
  6. DEV Express
  7. PS日记一
  8. 大数据学习——hadoop集群搭建2.X
  9. NYOJ-517-最小公倍数,大数啊~~~
  10. bzoj 1702 贪心,前缀和