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. js 将页面保存为图片

    <!DOCTYPE html><html><head><title>保存为images</title><meta charset=&q ...

  2. linux下使用docker方式部署ftp服务器

    linux环境下部署vsftpd比较繁琐,可以直接使用docker官方仓库中的pure-ftpd镜像来部署ftp服务器. 下载镜像 docker pull stilliard/pure-ftpd:ha ...

  3. Go:单元测试

    测试用的文件名必须以 _test.go 结尾: 测试用的函数名必须以 Test 开头,一般来说:Test+被测试的函数名(第一个字母必须大写): func TestXx(t *testing.T) { ...

  4. 网易技术分享:Nginx缓存引发的跨域惨案

    推荐:更多技术团队分享文章 关注:MAYOU18技术专栏 1. 前言 贵金属wap版直播间上线后,偶尔有用户反馈,在进入wap直播间的时候,出现空白页面,但是重新刷新又可以正常显示了.我们曾一度认为是 ...

  5. CSS3---关于文本

    1.text-overflow用来设置是否使用一个省略标记(...)标示对象内文本的溢出. 2.但是text-overflow只是用来说明文字溢出时用什么方式显示,要实现溢出时产生省略号的效果,还须定 ...

  6. C++:别名 / 引用 的简单实用

    文章来源:http://www.cnblogs.com/hello-tl/p/7910048.html /* C++别名操作 在更改别名的时候同时变量也会跟着改变 */ #include " ...

  7. JS 获取字符串中的url并返回其下标索引

    //获取字符串中的url极其下标索引 function getHttpUrlArray(s) { var s1 = s.match(/http.*/); if(s1 == null) { return ...

  8. pwnable.kr cmd1之write up

    看一下源代码: #include <stdio.h> #include <string.h> int filter(char* cmd){ ; r += strstr(cmd, ...

  9. set()集合基本操作

    运用频次:☆☆ set是一个无序且不重复元素集,基本操作如下: 1. 创建set集合,会自动转换成set类型 2. add():添加元素 def add(self, *args, **kwargs): ...

  10. CSS3 pointer-events:none 让你摆脱事件的烦恼

    以前没遇到这个属性,在一个偶然的博文下发现该属性真的好用,你是否遇到过写鼠标移入显示文本的效果时,鼠标在元素内的每一次移动都会造成要显示文本的闪烁或是突然的消失?只要在被控制的元素中加上这个属性完美解 ...