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. oracle插入多表(insert all/first)

    1.建测试表   CREATE TABLE EDW_INT   (     AGMT_NO         VARCHAR2(40 BYTE)             NOT NULL,     AG ...

  2. Ubuntu 和 centos7 服务的启动

    Ubuntu 下: /etc/init.d/nginx  start | stop | reload Centos7下: service nginx start | stop | reload

  3. ubuntu18.04 server配置静态ip

    最新发布的ubuntu18.04 server,启用了新的网络工具netplan,对于命令行配置网络参数跟之前的版本有比较大的差别,现在介绍如下:1.其网络配置文件是放在/etc/netplan/50 ...

  4. log4j 、logback 以及slf4j三者之间的关系

    在项目的开发中由于对于log4j.logback以及slf4j之间的关系和相关的知识不能清晰掌握,在业余时间进行记录. 1.三者之间的关系 1) 简答的讲就是slf4j是一系列的日志接口,而log4j ...

  5. vs2010 C# 如何将类做成DLL 再从另一个项目中使用这个类

    vs2010 C# 如何将类做成DLL 再从另一个项目中使用这个类 2011-10-20 12:00 486人阅读 评论(0) 收藏 举报 一.将类做成DLL 方法一: 你可以通过在命令行下用命令将以 ...

  6. python022 Python3 面向对象

    Python3 面向对象 Python从设计之初就已经是一门面向对象的语言,正因为如此,在Python中创建一个类和对象是很容易的.本章节我们将详细介绍Python的面向对象编程. 如果你以前没有接触 ...

  7. Flask---ajax(jquery)交互

    目录结构如下: |--| |--run.py |--static |--test.txt |--templates |--index.html 前端代码如下: index.html <!DOCT ...

  8. HDU-1858-Max Partial Value I,有坑点,不难;

    Max Partial Value I Time Limit: 1000/5000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Othe ...

  9. 【RMAN】RMAN跨版本恢复(下)--大版本异机恢复

    [RMAN]RMAN跨版本恢复(下)--大版本异机恢复 BLOG文档结构图 ORACLE_SID=ORA1024G 关于10g的跨小版本恢复参考:http://blog.chinaunix.net/u ...

  10. SpringMVC(8) - 处理器映射

    在以前的Spring版本中,用户需要在Web应用程序上下文中定义一个或多个HandlerMapping bean,以将传入的Web请求映射到适当的处理器.通过引入带注解的控制器,就不需要像之前那样定义 ...