Skip to content
This repository has been archived by the owner on Oct 11, 2019. It is now read-only.

Commit

Permalink
add toggle i18n menu
Browse files Browse the repository at this point in the history
  • Loading branch information
cute committed Jul 27, 2016
1 parent af5c661 commit 9266033
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>15F34</string>
<string>15G31</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<dict>
<key>Resources/Info.plist</key>
<data>
2MsGKqPe0Dr/A/KK1WTF8gw5yfk=
DVx2Hsrba0dtkUduTBmdmM6WkOA=
</data>
</dict>
<key>files2</key>
Expand Down Expand Up @@ -37,11 +37,11 @@
<dict>
<key>hash</key>
<data>
2MsGKqPe0Dr/A/KK1WTF8gw5yfk=
DVx2Hsrba0dtkUduTBmdmM6WkOA=
</data>
<key>hash2</key>
<data>
5skQW7ojeWrLGpuNafHUj7VooLOyUyakj0idHx9qO9M=
8JTARCWDiwxfCQvcVdS+kbVZVdBUYTHxsCl0IadyL9U=
</data>
</dict>
</dict>
Expand Down
6 changes: 3 additions & 3 deletions SketchI18N.sketchplugin/Contents/Resources/i18n/zh-Hans.json
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,6 @@
"Color Sliders": "Color Sliders",
"The selected layers will be replaced by a single layer. A new \nSymbol will be created in your document. Whenever this Symbol is edited, all its layers will update to reflect the changes.": "已选中的图层将被替换为单个图层。一个新的组件将创建到你的文档中。每当这个组件被编辑的时候,和它相关的图层将自动同步修改。",
"Item 1": "Item 1",
"Toggle Craft": "切换 Craft",
"pick color": "取色",
"No Value": "没有值",
"CUSTOM": "自定义",
Expand All @@ -765,7 +764,6 @@
"Dropbox Link": "Dropbox 链接",
"Random Unsplash": "随机 Unsplash",
"Sync Styles": "同步样式",
"Craft": "Craft",
"Folder": "文件夹",
"Data": "数据",
"Duplicate inside selection": "复制内部选择",
Expand All @@ -783,5 +781,7 @@
"Project": "项目",
"Author": "作者",
"Company": "公司",
"Change Code Settings...": "修改代码设置..."
"Change Code Settings...": "修改代码设置...",
"Define Text Styles by creating a new style from an existing text layer in the Inspector.": "从查看器中已经存在的文字图层,创建一个新的样式来定义文本样式。",
"Symbols let you reuse content in your design. Create a Symbol via Layer > Create Symbol": "组件可以让在在设计中重用内容. 创建一个组件通过 图层 > 创建组件"
}
10 changes: 7 additions & 3 deletions SketchI18N.sketchplugin/Contents/Sketch/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ var onRun = function(context) {
language = NSUserDefaults.standardUserDefaults().objectForKey("AppleLanguages").objectAtIndex(0),
languagePath = resourcesPath + "/Contents/Resources/i18n/" + language + ".json";

if(NSFileManager.defaultManager().fileExistsAtPath(languagePath)){
if (NSFileManager.defaultManager().fileExistsAtPath(languagePath)) {
var mocha = Mocha.sharedRuntime();
i18n = [NSString stringWithContentsOfFile:languagePath encoding:NSUTF8StringEncoding error:nil];
i18n = [NSString stringWithContentsOfFile: languagePath encoding: NSUTF8StringEncoding error: nil];

if (!NSClassFromString("SketchI18NPluginManager")) {
mocha.loadFrameworkWithName_inDirectory("SketchI18NPlugin", resourcesPath + "/Contents/Resources");
Expand All @@ -18,6 +18,10 @@ var onRun = function(context) {
} else {
manager = SketchI18NPluginManager.manager();
}
manager.run();
if (identifier == "i18n-toggle-command") {
manager.toggle();
} else {
manager.run();
}
}
}
13 changes: 9 additions & 4 deletions SketchI18N.sketchplugin/Contents/Sketch/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
"description": "Sketch I18N",
"author": "@liguangming",
"homepage": "http://liguangming.com",
"version": "1.0.5",
"version": "1.0.6",
"identifier": "com.liguangming.sketch-i18n",
"downloadURL": "https://github.com/cute/SketchI18N",
"compatibleVersion": 3.3,
"bundleVersion": "8",
"bundleVersion": "9",
"commands": [{
"name": "Sketch I18N",
"identifier": "i18n-command",
Expand All @@ -19,11 +19,16 @@
"OpenDocument": "onRun",
}
}
},{
"name": "Toggle I18N",
"identifier": "i18n-toggle-command",
"script": "app.js",
"handler": "onRun",
}],
"menu": {
"isRoot": true,
"isRoot": false,
"items": [
"i18n-command"
"i18n-toggle-command",
]
}
}

0 comments on commit 9266033

Please sign in to comment.