VS code - code Snippet
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的更多相关文章
- Vs code添加自定义snippet
Vs code添加自定义snippet(代码段) 前言 代码段能够帮助输入重复代码模式,在智能感知下可以帮我们快速补全代码,节省时间方便之余更利于代码格式的统一规范化. 1. Vs code代码段 ...
- 使用 Code Snippet 简化 Coding
在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...
- C# 使用 Code Snippet 简化 Coding
在开发的项目的时候,你是否经常遇到需要重复编写一些类似的代码,比如是否经常会使用 for.foreach ? 在编写这两个循环语句的时候,你是一个字符一个字符敲还是使用 Visual Studio 提 ...
- VS Code 列编辑功能说明
新版本v1.13.1或者附近的版本中的列编辑功能已经调整. 一.多光标插入功能 Alt+鼠标左键,添加多光标输入 二.自由多行选择 Alt键+鼠标左键拖动选择各行的部分内容 三.列选择 Shift+A ...
- 如何在 VS Code 中搭建 Qt 开发环境
前言 VS Code 高大上的界面.强大的智能联想和庞大的插件市场,着实让人对他爱不释手.虽然可以更改 Qt Creator 的主题,但是 Qt Creator 的代码体验实在差劲.下面就来看看如何在 ...
- docker4dotnet #3 在macOS上使用Visual Studio Code和Docker开发asp.net core和mysql应用
.net猿遇到了小鲸鱼,觉得越来越兴奋.本来.net猿只是在透过家里那田子窗看外面的世界,但是看着海峡对岸的苹果园越来越茂盛,实在不想再去做一只宅猿了.于是,.net猿决定搭上小鲸鱼的渡轮到苹果园去看 ...
- [转]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 ...
- [转]OAuth 2.0 - Authorization Code授权方式详解
本文转自:http://www.cnblogs.com/highend/archive/2012/07/06/oautn2_authorization_code.html I:OAuth 2.0 开发 ...
- 微信——获取用户基本信息及openid 、access_token、code
获取用户信息,需要获取 access_token.openid 然后调用接口https://api.weixin.qq.com/cgi-bin/user/info?access_token=ACCES ...
随机推荐
- ubuntu下操作Hadoop、hdfs、hbase、zookeeper时产生的一些问题及解决办法
2019/05/29 1.在终端输入jps时,没有显示Hdfs的DataNode 在文件夹中分别找到DataNode 和Namenode的version,将Datanode的version改为与nam ...
- 在Windows上安装和配置Jenkins
一.windows上安装Jenkins 1.官网下载Jenkins安装包Jenkins.msi ,进入安装模式,选择默认配置,安装完成之后,就会默认打开浏览器 http://localhost:808 ...
- MySQL redo log 与 binlog 的区别
MySQL redo log 与 binlog 的区别 什么是redo log 什么是binlog redo log与binlog的区别 1. 什么是redo log? redo log又称重做日志文 ...
- Oracle的五种约束
1.非空(NOT NULL)约束:所定义的列不绝对不能为空: 例如:将已经创建好的表BOOK中的bookname字段修改为不为空: 利用 ALTER TABLE.......MODIFY ...... ...
- running Fluent on Apocrita Cluster
two files: code.sh, code.jou code.sh #!/bin/bash #$ -cwd #$ -j y #$ -m bea #$ -M k.ai@qmul.ac.uk #$ ...
- POJ 3310 Caterpillar(图的度的判定)
题意: 给定一幅图, 问符不符合一下两个条件: (1) 图中没有环 (2)图中存在一条链, 点要么在链上, 要么是链上点的邻居. 分析: 建图,记录度数, 去掉所有度为1的点, 然后看看剩下是否是有2 ...
- BeautifulSoup4系列二
前言 本篇详细介绍beautifulsoup4的功能,从最基础的开始讲起,让小伙伴们都能入门 一.读取HTML页面 1.先写一个简单的html页面,把以下内容copy出来,保存为html格式文件 &l ...
- NYOJ 237 游戏高手的烦恼
游戏高手的烦恼时间限制:1000 ms | 内存限制:65535 KB难度:5描述有一位传说级游戏高手,在闲暇时间里玩起了一个小游戏,游戏中,一个n*n的方块形区域里有许多敌人,玩家可以使用炸弹炸掉某 ...
- CSU1030素数槽
Description 处于相邻的两个素数p和p + n之间的n - 1个连续的合数所组成的序列我们将其称为长度为n的素数槽.例如,‹24, 25, 26, 27, 28›是处于素数23和素数29之间 ...
- 【树形DP】codeforces K. Send the Fool Further! (medium)
http://codeforces.com/contest/802/problem/K [题意] 给定一棵树,Heidi从根结点0出发沿着边走,每个结点最多经过k次,求这棵树的最大花费是多少(同一条边 ...