) => {
const getLinks = useLinks(data.timeRange);
+ const panelId = useId();
+
if (!data || !data.series.length) {
return (
@@ -22,7 +24,11 @@ export const NodeGraphPanel = ({ width, height, data, options }: PanelProps
-
+
);
};
diff --git a/public/locales/i18next-parser-enterprise.config.cjs b/public/locales/i18next-parser-enterprise.config.cjs
new file mode 100644
index 00000000000..66e8cd9cca2
--- /dev/null
+++ b/public/locales/i18next-parser-enterprise.config.cjs
@@ -0,0 +1,8 @@
+const baseConfig = require('./i18next-parser.config.cjs');
+
+module.exports = {
+ ...baseConfig,
+ defaultNamespace: 'grafana-enterprise',
+ input: ['../../public/app/extensions/**/*.{tsx,ts}'],
+ output: './public/app/extensions/locales/$LOCALE/$NAMESPACE.json',
+};
diff --git a/public/locales/i18next-parser.config.cjs b/public/locales/i18next-parser.config.cjs
index 2aeca9d3745..f6c47aa7cc1 100644
--- a/public/locales/i18next-parser.config.cjs
+++ b/public/locales/i18next-parser.config.cjs
@@ -1,6 +1,6 @@
module.exports = {
- // Base config
- locales: ['en-US'], // Only en-US is updated - Crowdin will PR with other languages
+ // Base config - same for both OSS and Enterprise
+ locales: ['en-US'], // Only en-US is updated - Crowdin will PR with other languages
sort: true,
createOldCatalogs: false,
failOnWarnings: true,
@@ -9,6 +9,10 @@ module.exports = {
// OSS-specific config
defaultNamespace: 'grafana',
- input: ['../../public/**/*.{tsx,ts}', '!../../public/app/extensions/**/*', '../../packages/grafana-ui/**/*.{tsx,ts}'],
+ input: [
+ '../../public/**/*.{tsx,ts}',
+ '!../../public/app/extensions/**/*', // Don't extract from Enterprise
+ '../../packages/grafana-ui/**/*.{tsx,ts}',
+ ],
output: './public/locales/$LOCALE/$NAMESPACE.json',
};
diff --git a/public/locales/pseudo.js b/public/locales/pseudo.js
deleted file mode 100644
index 4bcfef5df05..00000000000
--- a/public/locales/pseudo.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const fs = require('fs/promises');
-const pseudoizer = require('pseudoizer');
-const prettier = require('prettier');
-
-function pseudoizeJsonReplacer(key, value) {
- if (typeof value === 'string') {
- // Split string on brace-enclosed segments. Odd indices will be {{variables}}
- const phraseParts = value.split(/(\{\{[^}]+}\})/g);
- const translatedParts = phraseParts.map((str, index) => index % 2 ? str : pseudoizer.pseudoize(str))
- return translatedParts.join("")
- }
-
- return value;
-}
-
-fs.readFile('./public/locales/en-US/grafana.json').then(async (enJson) => {
- const enMessages = JSON.parse(enJson);
- // Add newline to make prettier happy
- const pseudoJson = await prettier.format(JSON.stringify(enMessages, pseudoizeJsonReplacer, 2), {
- parser: 'json',
- });
-
- return fs.writeFile('./public/locales/pseudo-LOCALE/grafana.json', pseudoJson);
-});
diff --git a/public/locales/pseudo.mjs b/public/locales/pseudo.mjs
new file mode 100644
index 00000000000..05f3f89626d
--- /dev/null
+++ b/public/locales/pseudo.mjs
@@ -0,0 +1,63 @@
+// @ts-check
+import { readFile, writeFile } from 'fs/promises';
+import { format } from 'prettier';
+import { pseudoize } from 'pseudoizer';
+import { hideBin } from 'yargs/helpers';
+import yargs from 'yargs/yargs';
+
+const argv = await yargs(hideBin(process.argv))
+ .option('mode', {
+ demandOption: true,
+ describe: 'Path to a template to use for each issue. See source bettererIssueTemplate.md for an example',
+ type: 'string',
+ choices: ['oss', 'enterprise', 'both'],
+ })
+ .version(false).argv;
+
+const extractOSS = ['oss', 'both'].includes(argv.mode);
+const extractEnterprise = ['enterprise', 'both'].includes(argv.mode);
+
+/**
+ * @param {string} key
+ * @param {unknown} value
+ */
+function pseudoizeJsonReplacer(key, value) {
+ if (typeof value === 'string') {
+ // Split string on brace-enclosed segments. Odd indices will be {{variables}}
+ const phraseParts = value.split(/(\{\{[^}]+}\})/g);
+ const translatedParts = phraseParts.map((str, index) => (index % 2 ? str : pseudoize(str)));
+ return translatedParts.join('');
+ }
+
+ return value;
+}
+/**
+ * @param {string} inputPath
+ * @param {string} outputPath
+ */
+async function pseudoizeJson(inputPath, outputPath) {
+ const baseJson = await readFile(inputPath, 'utf-8');
+ const enMessages = JSON.parse(baseJson);
+ const pseudoJson = JSON.stringify(enMessages, pseudoizeJsonReplacer, 2);
+ const prettyPseudoJson = await format(pseudoJson, {
+ parser: 'json',
+ });
+
+ await writeFile(outputPath, prettyPseudoJson);
+ console.log('Wrote', outputPath);
+}
+
+//
+// OSS translations
+if (extractOSS) {
+ await pseudoizeJson('./public/locales/en-US/grafana.json', './public/locales/pseudo-LOCALE/grafana.json');
+}
+
+//
+// Enterprise translations
+if (extractEnterprise) {
+ await pseudoizeJson(
+ './public/app/extensions/locales/en-US/grafana-enterprise.json',
+ './public/app/extensions/locales/pseudo-LOCALE/grafana-enterprise.json'
+ );
+}
diff --git a/scripts/drone/steps/lib.star b/scripts/drone/steps/lib.star
index 85d435f7f7c..26070962065 100644
--- a/scripts/drone/steps/lib.star
+++ b/scripts/drone/steps/lib.star
@@ -641,7 +641,7 @@ def lint_frontend_step():
def verify_i18n_step():
extract_error_message = "\nExtraction failed. Make sure that you have no dynamic translation phrases, such as 't(\\`preferences.theme.\\$${themeID}\\`, themeName)' and that no translation key is used twice. Search the output for '[warning]' to find the offending file."
- uncommited_error_message = "\nTranslation extraction has not been committed. Please run 'yarn i18n:extract', commit the changes and push again."
+ uncommited_error_message = "\nTranslation extraction has not been committed. Please run 'make i18n-extract', commit the changes and push again."
return {
"name": "verify-i18n",
"image": images["node"],
@@ -651,7 +651,7 @@ def verify_i18n_step():
"failure": "ignore",
"commands": [
"apk add --update git",
- "yarn run i18n:extract || (echo \"{}\" && false)".format(extract_error_message),
+ "make i18n-extract || (echo \"{}\" && false)".format(extract_error_message),
# Verify that translation extraction has been committed
'''
file_diff=$(git diff --dirstat public/locales)
diff --git a/yarn.lock b/yarn.lock
index 700b3a5c9bb..39e99715e8d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -18365,8 +18365,8 @@ __metadata:
linkType: hard
"glob-stream@npm:^8.0.0":
- version: 8.0.0
- resolution: "glob-stream@npm:8.0.0"
+ version: 8.0.2
+ resolution: "glob-stream@npm:8.0.2"
dependencies:
"@gulpjs/to-absolute-glob": "npm:^4.0.0"
anymatch: "npm:^3.1.3"
@@ -18376,7 +18376,7 @@ __metadata:
is-negated-glob: "npm:^1.0.0"
normalize-path: "npm:^3.0.0"
streamx: "npm:^2.12.5"
- checksum: 10/b1d18b6fd49086ff02e031f03e3debac747047d304b349a6dced3b7944c665344ef63496363f483acc7c6afcd6ebfb11af1652824f2c370d83c0f3905d5c67e0
+ checksum: 10/cda46c02b6313d4a5cd0a3e67c7a2bd477d5f708904dc761c0d6364611f188a303051ec4e0cd405597522c7f7ffbba530f147754b4bf5af9f18e970c024734d8
languageName: node
linkType: hard