Skip to content

Commit

Permalink
build(docs): lookup English l10n value for doc rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Oct 29, 2023
1 parent d65c3ba commit 3f086f9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ This extension makes the following commands available in the Command Palette to
| `Titanium: Open related style` | Open related style | Mac: <kbd>cmd</kbd>+<kbd>alt</kbd>+<kbd>s</kbd> <br> Windows/Linux: <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>s</kbd> |
| `Titanium: Open related controller` | Open related controller | Mac: <kbd>cmd</kbd>+<kbd>alt</kbd>+<kbd>x</kbd> <br> Windows/Linux: <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>x</kbd> |
| `Titanium: Open related files` | Open related files | Mac: <kbd>cmd</kbd>+<kbd>alt</kbd>+<kbd>a</kbd> <br> Windows/Linux: <kbd>ctrl</kbd>+<kbd>alt</kbd>+<kbd>a</kbd> |
| `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 | - |
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
2 changes: 2 additions & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
22 changes: 16 additions & 6 deletions scripts/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -40,8 +41,8 @@ function generateCommands() {
continue;
}
commandInformation.push({
name: `\`${category}: ${title}\``,
description: description || title,
name: `\`${category}: ${getEnglishl10nValue(title)}\``,
description: getEnglishl10nValue(description || title),
keybinding
});

Expand All @@ -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}\``
});
}
Expand Down Expand Up @@ -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')) {
Expand All @@ -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)
});
Expand Down Expand Up @@ -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'
});
Expand All @@ -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;
}

0 comments on commit 3f086f9

Please sign in to comment.