From e40fd14ce13b5a46518e2c56fc7fdbd94c4389cf Mon Sep 17 00:00:00 2001 From: Ewan Harris Date: Sat, 2 Sep 2023 16:22:19 +0100 Subject: [PATCH] build(docs): lookup English l10n value for doc rendering --- README.md | 1 + package.json | 4 ++-- package.nls.json | 2 ++ scripts/render.js | 22 ++++++++++++++++------ 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 5b53cba42..e6e953c3d 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ This extension makes the following commands available in the Command Palette to | `Titanium: Open related style` | Open related style | Mac: cmd+alt+s
Windows/Linux: ctrl+alt+s | | `Titanium: Open related controller` | Open related controller | Mac: cmd+alt+x
Windows/Linux: ctrl+alt+x | | `Titanium: Open related files` | Open related files | Mac: cmd+alt+a
Windows/Linux: ctrl+alt+a | +| `Titanium: Fix environment issues` | Fix environment issues | - | | `Titanium: Check For Updates` | Check For Updates | - | | `Titanium: Install All Updates` | Install All Updates | - | | `Titanium: Select Updates` | Select Updates | - | diff --git a/package.json b/package.json index d55350cf2..e0807a316 100644 --- a/package.json +++ b/package.json @@ -896,11 +896,11 @@ "description": "%titanium.tasks.titanium-package.android.keystore%", "properties": { "alias": { - "description": "Alias for the keystore", + "description": "titanium.tasks.titanium-package.android.keystore.alias", "type": "string" }, "location": { - "description": "Path of the keystore to be used, must be a full path", + "description": "titanium.tasks.titanium-package.android.keystore.location", "type": "string" } } diff --git a/package.nls.json b/package.nls.json index bd093732c..3bcb9d5ff 100644 --- a/package.nls.json +++ b/package.nls.json @@ -72,6 +72,8 @@ "titanium.tasks.titanium-package.titaniumBuild": "Properties used to configure the build", "titanium.tasks.titanium-package.android": "Properties used to configure Android builds", "titanium.tasks.titanium-package.android.keystore": "Keystore configuration", + "titanium.tasks.titanium-package.android.keystore.alias": "Alias for the keystore", + "titanium.tasks.titanium-package.android.keystore.location": "Path of the keystore to be used, must be a full path", "titanium.tasks.titanium-package.extraArguments": "Extra arguments to be used in the build", "titanium.tasks.titanium-package.ios": "Properties used to configure iOS builds", "titanium.tasks.titanium-package.ios.provisioningProfile": "Provisioning Profile UUID to be used", diff --git a/scripts/render.js b/scripts/render.js index 63582fc6f..2f7aef65d 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -2,6 +2,7 @@ const ejs = require('ejs'); const fs = require('fs-extra'); const packageJson = require('../package.json'); const path = require('path'); +const strings = fs.readJSONSync(path.join(__dirname, '..', 'package.nls.json')); const renderObject = { commands: generateCommands(), @@ -40,8 +41,8 @@ function generateCommands() { continue; } commandInformation.push({ - name: `\`${category}: ${title}\``, - description: description || title, + name: `\`${category}: ${getEnglishl10nValue(title)}\``, + description: getEnglishl10nValue(description || title), keybinding }); @@ -56,7 +57,7 @@ function generateSettings() { const defaultValue = settingInfo.default === null || settingInfo.default.length === 0 ? 'No Default' : settingInfo.default; settingsInformation.push({ name: `\`${name}\``, - description: settingInfo.description, + description: getEnglishl10nValue(settingInfo.description), defaultValue: `\`${defaultValue}\`` }); } @@ -104,7 +105,7 @@ function generateSnippets() { for (const { description, prefix } of Object.values(snippetDefinitions)) { snippetInfo.push({ prefix: `\`${prefix}\``, - description + description: description }); } if (description.includes('Titanium')) { @@ -127,7 +128,7 @@ function generateDebugProperties () { for (const [ name, information ] of Object.entries(properties)) { debuggingInformation.launch.push({ name, - description: information.description, + description: getEnglishl10nValue(information.description), defaultValue: information.defaultValue, required: required.includes(name) }); @@ -186,7 +187,7 @@ function recurseProperties(properties, platform, taskType, propertyPrefix = 'tit } propertyData.push({ name: `\`${propertyPrefix}.${name}\``, - description: information.description, + description: getEnglishl10nValue(information.description), defaultValue: information.defaultValue, validValues: information.enum ? information.enum.map(value => `\`${value}\``).join(', ') : 'N/A' }); @@ -196,3 +197,12 @@ function recurseProperties(properties, platform, taskType, propertyPrefix = 'tit } return propertyData; } + +function getEnglishl10nValue(name) { + const val = strings[name.replaceAll('%', '')]; + if (!val) { + console.warn(`Failed to lookup ${name} in package.nls.json`); + return ''; + } + return val; +}