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.

VS code - code Snippet的更多相关文章

  1. Vs code添加自定义snippet

    Vs code添加自定义snippet(代码段) 前言 ​ 代码段能够帮助输入重复代码模式,在智能感知下可以帮我们快速补全代码,节省时间方便之余更利于代码格式的统一规范化. 1. Vs code代码段 ...

  2. 使用 Code Snippet 简化 Coding

    在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...

  3. C# 使用 Code Snippet 简化 Coding

    在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...

  4. VS Code 列编辑功能说明

    新版本v1.13.1或者附近的版本中的列编辑功能已经调整. 一.多光标插入功能 Alt+鼠标左键,添加多光标输入 二.自由多行选择 Alt键+鼠标左键拖动选择各行的部分内容 三.列选择 Shift+A ...

  5. 如何在 VS Code 中搭建 Qt 开发环境

    前言 VS Code 高大上的界面.强大的智能联想和庞大的插件市场,着实让人对他爱不释手.虽然可以更改 Qt Creator 的主题,但是 Qt Creator 的代码体验实在差劲.下面就来看看如何在 ...

  6. docker4dotnet #3 在macOS上使用Visual Studio Code和Docker开发asp.net core和mysql应用

    .net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对岸的苹果园越来越茂盛,实在不想再去做一只宅猿了.于是,.net猿决定搭上小鲸鱼的渡轮到苹果园去看 ...

  7. [转]Code! MVC 5 App with Facebook, Twitter, LinkedIn and Google OAuth2 Sign-on (C#)

    本文转自:https://www.asp.net/mvc/overview/security/create-an-aspnet-mvc-5-app-with-facebook-and-google-o ...

  8. [转]OAuth 2.0 - Authorization Code授权方式详解

    本文转自:http://www.cnblogs.com/highend/archive/2012/07/06/oautn2_authorization_code.html I:OAuth 2.0 开发 ...

  9. 微信——获取用户基本信息及openid 、access_token、code

    获取用户信息,需要获取 access_token.openid 然后调用接口https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCES ...

随机推荐

  1. Visual Studio 安装VS10x CodeMAP

    最近出差,用的是公司电脑,电脑安装的是Visual Studio 2017 VS10x CodeMap 支持Visual Studio 2010, 2012, 2013, 2015,不支持Visual ...

  2. jQuery闪烁提示,让新消息在网页标题显示

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head& ...

  3. [kuangbin带你飞]专题五 并查集

    并查集的介绍可以看下https://www.cnblogs.com/jkzr/p/10290488.html A - Wireless Network POJ - 2236 An earthquake ...

  4. 约束RMQ

    不知道为什么网上找不到太多相关的资料,所以写一个小总结,并附有能用的代码,抛砖引玉. 约束RMQ,就是RMQ区间必须满足两项之差最大为1,采用ST表的话,这时候有O(n)建表,O(1)查询的优秀复杂度 ...

  5. perl学习之:use & require

    相同: 都可以用来引用module(.PM). 不同: 1) 区别在于USE是在当前默认的@INC里面去寻找,一旦模块不在@INC中的话,用USE是不可以引入的,但是require可以指定路径: 2) ...

  6. python基础 : 1.计算机基础 2.注释 3.变量 4.标识符 5.输出 6.格式化输出 7.输入 8.算数运算符 9.字符串操作

  7. Centos6.5安装Nexus及安装时的一些错误

    注意:此篇博文未有配置部分,有需求的同学只能自行寻找了-- 1.下载: https://www.sonatype.com/download-oss-sonatype 2.官方推荐安装在/opt目录下 ...

  8. mysql查最大字符串

    select MAX(comp_code+0) from t_base_company 字符串 +0 把字符串转成数字

  9. Codevs 3556 科技庄园==洛谷 P2760

    时间限制: 1 s  空间限制: 128000 KB  题目等级 : 黄金 Gold 题目描述 Description Life是codevs的用户,他是一个道德极高的用户,他积极贯彻党的十八大精神, ...

  10. linux 安装问题make: 没有指明目标并且找不到makefile。 停止

    错误发生的可能原因,忘记安装软件需要的依赖.