You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/plugin_developer_guide.md
+25-8Lines changed: 25 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1114,6 +1114,8 @@ You can find other examples in [tests](https://github.com/maxbrunsfeld/counterfe
1114
1114
1115
1115
IBM Cloud CLI tends to be used globally. Both IBM Cloud CLI and its plug-ins should support globalization. We have enabled internationalization (i18n) for CLI's base commands with the help of the third-party tool "[go-i18n](https://github.com/nicksnyder/go-i18n)". To keep user experience consistent, we recommend plug-in developers follow the CLI's way of i18n enablement.
1116
1116
1117
+
Please install the *go-i18n* CLI for version 1.10.0. Newer versions of the CLI are no longer compatible with translations files prior to go-i18n@2.0.0. You can install the CLI using the command: `go install github.com/nicksnyder/go-i18n/goi18n@1.10.1`
1118
+
1117
1119
Here's the workflow:
1118
1120
1119
1121
1. Add new strings or replace existing strings with `T()` function calls to load the translated strings. For example:
@@ -1149,10 +1151,10 @@ Here's the workflow:
1149
1151
1. Create empty files `zh-hans.all.json` and `fr-br.all.json`, and run:
The previous command will generate 2 output files for each language: `xx-yy.all.json` contains all strings for the language, and `xx-yy.untranslated.json` contains untranslated strings. After the strings are translated, they should be merged back into `xx-yy.all.json`. For more details, refer to goi18n CLI's help by 'goi18n –help'.
1157
+
The previous command will generate 2 output files for each language: `xx-yy.all.json` contains all strings for the language, and `xx-yy.untranslated.json` contains untranslated strings. After the strings are translated, they should be merged back into `xx-yy.all.json`. If plugin is on the ibm-cloud-cli-sdk 1.00 or above, rename the file from `xx-yy.all.json` to `all.xx-yy.json`. For more details, refer to goi18n CLI's help by 'goi18n –help'.
1156
1158
1157
1159
3. Package translation files. IBM Cloud CLI is to be built as a stand-alone binary distribution. In order to load i18n resource files in code, we use [go-bindata](https://github.com/jteeuwen/go-bindata) to auto-generate Go source code from all i18n resource files and the compile them into the binary. You can write a script to do it automatically during build. A sample script could be like:
1158
1160
@@ -1174,34 +1176,49 @@ Here's the workflow:
1174
1176
`T()` must be initialized before use. During i18n initialization in IBM Cloud CLI, user locale is used if it's set in `~/.bluemix/config.json` (plug-in can get user locale via `PluginContext.Locale()`). Otherwise, system locale is auto discovered (see [jibber\_jabber](https://github.com/cloudfoundry/jibber_jabber)) and used. If system locale is not detected or supported, default locale `en\_US` is then used. Next, we initialize the translate function with the locale. Sample code:
### 8.1. HonourRegion/Resource GroupSetting of CLI
1217
+
### 8.1. HonorRegion/Resource GroupSetting of CLI
1201
1218
1202
1219
When users are using CLI, they probably have already targeted region or resource group during login. It's cumbersome to ask users to re-target region or resource group in specific command again.
1203
1220
1204
-
- By default, plugin should honour the region/resource group setting of CLI. Check `CurrentRegion`, `HasTargetedRegion`, `CurrentResourceGroup`, and `HasTargetedResourceGroup` in the [`core_config.Repository`](https://godoc.org/github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration/core_config#Repository).
1221
+
- By default, plugin should honor the region/resource group setting of CLI. Check `CurrentRegion`, `HasTargetedRegion`, `CurrentResourceGroup`, and `HasTargetedResourceGroup` in the [`core_config.Repository`](https://godoc.org/github.com/IBM-Cloud/ibm-cloud-cli-sdk/bluemix/configuration/core_config#Repository).
0 commit comments