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 ...
随机推荐
- WebGL 绘制Line的bug(一)
今天说点跟WebGL相关的事儿,不知道大家有没有碰到过类似的烦恼. 熟悉WebGL的同学都知道,WebGL绘制模式有点.线.面三种:通过点的绘制可以实现粒子系统等,通过线可以绘制一些连线关系:面就强大 ...
- 字典(trie)树--从入门到入土
今天再来认识一个强大的数据结构. 字典树又称单词查找树,Trie树,是一种树形结构,是一种哈希树的变种.典型应用是用于统计,排序和保存大量的字符串(但不仅限于字符串),所以经常被搜索引擎系统用于文本词 ...
- minGW64编译Qt
1.安装minGW64,设置bin目录到环境变量Path 2.cmd 到qt的Src目录 3.configure -debug-and-release -opensource -prefix &quo ...
- 删除mysql中user为空用户,mysql空密码
进入mysql数据库 mysql -uroot -p 查看用户信息 select user,host ,Password from mysql.user; 如下图: 删除user为空用户 delete ...
- win7下qt error: undefined reference to `_imp__getnameinfo@28'解决
_imp__getnameinfo@28对应着winsock2.h的getnameinfo函数 首先需要导入对应的头文件 #ifndef WIN32 #include <sys/socket.h ...
- Android开发——程序锁的实现(可用于开发钓鱼登录界面)
1. 程序锁原理 1.1 实现效果: 在用户打开一个应用时,若此应用是我们业务内的逻辑拦截目标,那就在开启应用之后,弹出一个输入密码的界面,输入密码正确则进入目标应用.若不输入直接按返回键,则直接返回 ...
- xtu DP Training C.炮兵阵地
炮兵阵地 Time Limit: 2000ms Memory Limit: 65536KB This problem will be judged on PKU. Original ID: 11856 ...
- Exact Change(01背包)
描述 Seller: That will be fourteen dollars. Buyer: Here's a twenty. Seller: Sorry, I don't have any ch ...
- CodeForces - 601A The Two Routes
http://codeforces.com/problemset/problem/601/A 这道题没想过来, 有点脑筋急转弯的感觉了 本质上就是找最短路径 但是卡在不能重复走同一个点 ----> ...
- HDU 1402 大数乘法 FFT、NTT
A * B Problem Plus Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Other ...