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 ...
随机推荐
- 使用 Pytorch 实现 skip-gram 的 word2vec
转载请注明 AIQ - 最专业的机器学习大数据社区 http://www.6aiq.com AIQ 机器学习大数据 知乎专栏 点击关注 链接地址: https://github.com/lonePa ...
- 2015 提高组 信息传递--tarjan找最小环
P2661 信息传递 题目描述 有 n 个同学(编号为 1 到 n )正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为 i 的同学的信息传递对象是编号为 Ti 的同学. ...
- 使用dockerfile构建nginx镜像
使用dockerfile构建nginx镜像 docker构建镜像的方法: commit.dockerfile 1.使用commit来构建镜像: commit是基于原有镜像基础上构建的镜像,使用此方 ...
- 如何用纯 CSS 创作一个充电 loader 特效
效果预览 在线演示 按下右侧的"点击预览"按钮在当前页面预览,点击链接全屏预览. https://codepen.io/zhang-ou/pen/deNqdV 可交互视频教程 此视 ...
- JavaScript 高级技巧 Memoization
memoization 来源于拉丁语 memorandum ("to be remembered"),不要与 memorization 混淆了. 首先来看一下维基百科的描述: In ...
- 【HIHOCODER 1575】 两个机器人(BFS)
描述 一个N × M的2D迷宫中有两个机器人.机器人A在迷宫左上角,只能向右或向下移动:机器人B在迷宫右下角,只能向左或向上移动.机器人不能移动到迷宫外.此外,由于奇怪的同步机制,这两个机器人只能同时 ...
- 跟初学者学习IbatisNet第四篇
这一章我们主要介绍一下IbatisNet里面的其它用法主要有以下几点: 1,如何得到运行时ibatis.net动态生成的SQL语句? 2,如何获取DbCommand? 3,如何返回DataTable, ...
- python的unittest单元测试框架断言整理汇总
自动化脚本最重要的是断言,正确设置断言以后才能帮助我们判断测试用例执行结果. 一.先说说unittest常用的断言吧 常用的就以下几个,网上一搜一大堆.python版本2.7以上都可以调用了. 断言语 ...
- NYOJ-481平衡字符串
平衡字符串 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描述 给你一定长度的字符串.字符串中只包含26个小写字母,首先我们把字母a-z分为2堆(a--m)和(n--z),判 ...
- CodeForces230A
题目大意: 一个打恐龙的游戏,有初始体力s,和恐龙n只,然后输入n只恐龙的体力xi,和击杀它得到的奖励体力yi,只有自身体力大于恐龙体力时才能进行击杀,击杀恐龙的顺序可以不定 这题运用到了贪心的思想, ...