From ac7150a0f876775eeb35f53408e07e7c759925f3 Mon Sep 17 00:00:00 2001 From: Miki Date: Tue, 1 Oct 2024 00:14:48 -0700 Subject: [PATCH] Split .i18nrc across `src`, `packages`, and `examples` Also: * Force validation of i18n even when no translations are available * Allow including translations in built artifacts Signed-off-by: Miki --- .i18nrc.json | 77 ----------------- examples/.i18nrc.json | 12 +++ packages/.i18nrc.json | 6 ++ src/.i18nrc.json | 85 +++++++++++++++++++ src/dev/build/args.test.ts | 10 +++ src/dev/build/args.ts | 2 + src/dev/build/build_distributables.ts | 6 ++ src/dev/build/cli.ts | 1 + src/dev/build/tasks/copy_source_task.ts | 1 - src/dev/build/tasks/copy_translations_task.ts | 51 +++++++++++ src/dev/build/tasks/index.ts | 1 + src/dev/i18n/config.ts | 38 +++++++-- src/dev/i18n/constants.ts | 3 + src/dev/i18n/index.ts | 9 +- src/dev/i18n/tasks/check_configs.ts | 10 ++- src/dev/i18n/tasks/merge_configs.ts | 11 ++- src/dev/run_i18n_check.ts | 4 +- src/dev/run_i18n_extract.ts | 3 +- src/dev/run_i18n_integrate.ts | 3 +- src/legacy/server/i18n/index.ts | 1 - src/plugins/data_explorer/.i18nrc.json | 7 -- src/plugins/query_enhancements/.i18nrc.json | 7 -- 22 files changed, 237 insertions(+), 111 deletions(-) delete mode 100644 .i18nrc.json create mode 100644 examples/.i18nrc.json create mode 100644 packages/.i18nrc.json create mode 100644 src/.i18nrc.json create mode 100644 src/dev/build/tasks/copy_translations_task.ts delete mode 100644 src/plugins/data_explorer/.i18nrc.json delete mode 100644 src/plugins/query_enhancements/.i18nrc.json diff --git a/.i18nrc.json b/.i18nrc.json deleted file mode 100644 index 91d3b80b80a0..000000000000 --- a/.i18nrc.json +++ /dev/null @@ -1,77 +0,0 @@ -{ - "paths": { - "common.ui": "src/legacy/ui", - "console": "src/plugins/console", - "core": "src/core", - "discover": "src/plugins/discover", - "dashboard": "src/plugins/dashboard", - "data": "src/plugins/data", - "embeddableApi": "src/plugins/embeddable", - "embeddableExamples": "examples/embeddable_examples", - "uiActionsExamples": "examples/ui_action_examples", - "share": "src/plugins/share", - "home": "src/plugins/home", - "flot": "packages/osd-ui-shared-deps/flot_charts", - "charts": "src/plugins/charts", - "opensearchUi": "src/plugins/opensearch_ui_shared", - "devTools": "src/plugins/dev_tools", - "expressions": "src/plugins/expressions", - "inputControl": "src/plugins/input_control_vis", - "inspector": "src/plugins/inspector", - "inspectorViews": "src/legacy/core_plugins/inspector_views", - "interpreter": "src/legacy/core_plugins/interpreter", - "osd": "src/legacy/core_plugins/opensearch-dashboards", - "osdDocViews": "src/legacy/core_plugins/osd_doc_views", - "osdDocViewsLinks": "src/legacy/core_plugins/osd_doc_views_links", - "management": [ - "src/legacy/core_plugins/management", - "src/plugins/management" - ], - "maps_legacy": "src/plugins/maps_legacy", - "indexPatternManagement": "src/plugins/index_pattern_management", - "advancedSettings": "src/plugins/advanced_settings", - "opensearch_dashboards_legacy": "src/plugins/opensearch_dashboards_legacy", - "opensearchDashboardsOverview": "src/plugins/opensearch_dashboards_overview", - "opensearch_dashboards_react": "src/legacy/core_plugins/opensearch_dashboards_react", - "opensearch-dashboards-react": "src/plugins/opensearch_dashboards_react", - "opensearch_dashboards_utils": "src/plugins/opensearch_dashboards_utils", - "navigation": "src/plugins/navigation", - "newsfeed": "src/plugins/newsfeed", - "regionMap": "src/plugins/region_map", - "savedObjects": "src/plugins/saved_objects", - "savedObjectsManagement": "src/plugins/saved_objects_management", - "security": "src/plugins/security_oss", - "server": "src/legacy/server", - "statusPage": "src/legacy/core_plugins/status_page", - "telemetry": [ - "src/plugins/telemetry", - "src/plugins/telemetry_management_section" - ], - "tileMap": "src/plugins/tile_map", - "timeline": ["src/plugins/vis_type_timeline"], - "uiActions": "src/plugins/ui_actions", - "visDefaultEditor": "src/plugins/vis_default_editor", - "visTypeMarkdown": "src/plugins/vis_type_markdown", - "visTypeMetric": "src/plugins/vis_type_metric", - "visTypeTable": "src/plugins/vis_type_table", - "visTypeTagCloud": "src/plugins/vis_type_tagcloud", - "visTypeTimeseries": "src/plugins/vis_type_timeseries", - "visTypeVega": "src/plugins/vis_type_vega", - "visTypeVislib": "src/plugins/vis_type_vislib", - "visTypeXy": "src/plugins/vis_type_xy", - "visualizations": "src/plugins/visualizations", - "visualize": "src/plugins/visualize", - "usageCollection": "src/plugins/usage_collection" - }, - "exclude": [ - "src/legacy/ui/ui_render/ui_render_mixin.js", - "src/plugins/home/public/application/components/tutorial", - "src/plugins/home/server/tutorials", - "src/core/server/rendering/views/template.tsx", - "src/plugins/data/public/search/errors/timeout_error.tsx", - "src/plugins/home/public/application/components/welcome.tsx", - "src/plugins/vis_type_timeline/server/series_functions/graphite.js", - "src/plugins/vis_type_timeseries/public/application/components/aggs/serial_diff.js" - ], - "translations": [] -} diff --git a/examples/.i18nrc.json b/examples/.i18nrc.json new file mode 100644 index 000000000000..a9e5ac5e83e4 --- /dev/null +++ b/examples/.i18nrc.json @@ -0,0 +1,12 @@ +{ + "paths": { + "embeddableExamples": "embeddable_examples", + "expressionsExample": "expressions_example", + "multipleDataSourceExample": "multiple_data_source_examples", + "searchExamples": "search_examples", + "stateContainerExamples": "state_containers_examples", + "uiActionsExamples": "ui_action_examples", + "uiActionsExplorer": "ui_actions_explorer" + }, + "translations": [] +} diff --git a/packages/.i18nrc.json b/packages/.i18nrc.json new file mode 100644 index 000000000000..210e55d70b58 --- /dev/null +++ b/packages/.i18nrc.json @@ -0,0 +1,6 @@ +{ + "paths": { + "flot": "osd-ui-shared-deps/flot_charts" + }, + "translations": [] +} diff --git a/src/.i18nrc.json b/src/.i18nrc.json new file mode 100644 index 000000000000..00e3e20afe8e --- /dev/null +++ b/src/.i18nrc.json @@ -0,0 +1,85 @@ +{ + "paths": { + "advancedSettings": "plugins/advanced_settings", + "apmOss": "plugins/apm_oss", + "charts": "plugins/charts", + "common.ui": "legacy/ui", + "console": "plugins/console", + "contentManagement": "plugins/content_management", + "core": "core", + "dashboard": "plugins/dashboard", + "data": "plugins/data", + "dataExplorer": "plugins/data_explorer", + "dataSourcesManagement": "plugins/data_source_management", + "devTools": "plugins/dev_tools", + "discover": "plugins/discover", + "embeddableApi": "plugins/embeddable", + "expressions": "plugins/expressions", + "home": "plugins/home", + "indexPatternManagement": "plugins/index_pattern_management", + "inputControl": "plugins/input_control_vis", + "inspector": "plugins/inspector", + "inspectorViews": "legacy/core_plugins/inspector_views", + "interpreter": "legacy/core_plugins/interpreter", + "management": [ + "legacy/core_plugins/management", + "plugins/management", + "plugins/management_overview" + ], + "maps_legacy": "plugins/maps_legacy", + "navigation": "plugins/navigation", + "newsfeed": "plugins/newsfeed", + "opensearch_dashboards_legacy": "plugins/opensearch_dashboards_legacy", + "opensearchDashboardsOverview": "plugins/opensearch_dashboards_overview", + "opensearch-dashboards-react": "plugins/opensearch_dashboards_react", + "opensearch_dashboards_react": "legacy/core_plugins/opensearch_dashboards_react", + "opensearch_dashboards_utils": "plugins/opensearch_dashboards_utils", + "opensearchUi": "plugins/opensearch_ui_shared", + "osd": "legacy/core_plugins/opensearch-dashboards", + "osdDocViews": "legacy/core_plugins/osd_doc_views", + "osdDocViewsLinks": "legacy/core_plugins/osd_doc_views_links", + "queryEnhancements": "plugins/query_enhancements", + "regionMap": "plugins/region_map", + "savedObjects": "plugins/saved_objects", + "savedObjectsManagement": "plugins/saved_objects_management", + "security": "plugins/security_oss", + "server": "legacy/server", + "share": "plugins/share", + "statusPage": "legacy/core_plugins/status_page", + "telemetry": [ + "plugins/telemetry", + "plugins/telemetry_management_section" + ], + "tileMap": "plugins/tile_map", + "timeline": [ + "plugins/vis_type_timeline" + ], + "uiActions": "plugins/ui_actions", + "usageCollection": "plugins/usage_collection", + "visAugmenter": "plugins/vis_augmenter", + "visBuilder": "plugins/vis_builder", + "visDefaultEditor": "plugins/vis_default_editor", + "visTypeMarkdown": "plugins/vis_type_markdown", + "visTypeMetric": "plugins/vis_type_metric", + "visTypeTable": "plugins/vis_type_table", + "visTypeTagCloud": "plugins/vis_type_tagcloud", + "visTypeTimeseries": "plugins/vis_type_timeseries", + "visTypeVega": "plugins/vis_type_vega", + "visTypeVislib": "plugins/vis_type_vislib", + "visTypeXy": "plugins/vis_type_xy", + "visualizations": "plugins/visualizations", + "visualize": "plugins/visualize", + "workspace": "plugins/workspace" + }, + "exclude": [ + "legacy/ui/ui_render/ui_render_mixin.js", + "plugins/home/public/application/components/tutorial", + "plugins/home/server/tutorials", + "core/server/rendering/views/template.tsx", + "plugins/data/public/search/errors/timeout_error.tsx", + "plugins/home/public/application/components/welcome.tsx", + "plugins/vis_type_timeline/server/series_functions/graphite.js", + "plugins/vis_type_timeseries/public/application/components/aggs/serial_diff.js" + ], + "translations": [] +} diff --git a/src/dev/build/args.test.ts b/src/dev/build/args.test.ts index 4a3489044eb7..8b5c3592607c 100644 --- a/src/dev/build/args.test.ts +++ b/src/dev/build/args.test.ts @@ -66,6 +66,7 @@ it('build dist for current platform, without packages, by default', () => { "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -96,6 +97,7 @@ it('build dist for linux x64 platform, without packages, if --linux is passed', "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -126,6 +128,7 @@ it('build dist for linux arm64 platform, without packages, if --linux-arm is pas "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -156,6 +159,7 @@ it('build dist for darwin x64 platform, without packages, if --darwin is passed' "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -186,6 +190,7 @@ it('build dist for windows x64 platform, without packages, if --windows is passe "windows": true, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -216,6 +221,7 @@ it('builds packages if --all-platforms is passed', () => { "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -246,6 +252,7 @@ it('limits packages if --rpm passed with --all-platforms', () => { "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -276,6 +283,7 @@ it('limits packages if --deb passed with --all-platforms', () => { "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -307,6 +315,7 @@ it('limits packages if --docker passed with --all-platforms', () => { "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, @@ -338,6 +347,7 @@ it('limits packages if --docker passed with --skip-docker-ubi and --all-platform "windows": false, }, "versionQualifier": "", + "withTranslations": false, }, "log": , "showHelp": false, diff --git a/src/dev/build/args.ts b/src/dev/build/args.ts index c7b6c9aaf32f..4da619b889ca 100644 --- a/src/dev/build/args.ts +++ b/src/dev/build/args.ts @@ -60,6 +60,7 @@ export function readCliArgs(argv: string[]) { 'silent', 'debug', 'help', + 'with-translations', ], alias: { v: 'verbose', @@ -139,6 +140,7 @@ export function readCliArgs(argv: string[]) { linuxArm: Boolean(flags['linux-arm']), }, targetAllPlatforms: Boolean(flags['all-platforms']), + withTranslations: Boolean(flags['with-translations']), }; return { diff --git a/src/dev/build/build_distributables.ts b/src/dev/build/build_distributables.ts index d764c5df280b..193ece29862e 100644 --- a/src/dev/build/build_distributables.ts +++ b/src/dev/build/build_distributables.ts @@ -46,6 +46,7 @@ export interface BuildOptions { versionQualifier: string | undefined; targetAllPlatforms: boolean; targetPlatforms: TargetPlatforms; + withTranslations: boolean; } export async function buildDistributables(log: ToolingLog, options: BuildOptions) { @@ -70,6 +71,11 @@ export async function buildDistributables(log: ToolingLog, options: BuildOptions * run platform-generic build tasks */ await run(Tasks.CopySource); + + if (options.withTranslations) { + // control w/ --with-translations + await run(Tasks.CopyTranslations); + } await run(Tasks.CopyBinScripts); await run(Tasks.CreateEmptyDirsAndFiles); await run(Tasks.CreateReadme); diff --git a/src/dev/build/cli.ts b/src/dev/build/cli.ts index 2287696c87ca..4935a45823e4 100644 --- a/src/dev/build/cli.ts +++ b/src/dev/build/cli.ts @@ -70,6 +70,7 @@ if (showHelp) { --release {dim Produce a release-ready distributable} --version-qualifier {dim Suffix version with a qualifier} --skip-node-download {dim Reuse existing downloads of node.js} + --with-translations {dim Include available translations} --verbose,-v {dim Turn on verbose logging} --no-debug {dim Turn off debug logging} `) + '\n' diff --git a/src/dev/build/tasks/copy_source_task.ts b/src/dev/build/tasks/copy_source_task.ts index 9605e1922c28..9d8cf1c525df 100644 --- a/src/dev/build/tasks/copy_source_task.ts +++ b/src/dev/build/tasks/copy_source_task.ts @@ -61,7 +61,6 @@ export const CopySource: Task = { 'config/opensearch_dashboards.yml', 'config/node.options', 'tsconfig*.json', - '.i18nrc.json', 'opensearch_dashboards.d.ts', ], }); diff --git a/src/dev/build/tasks/copy_translations_task.ts b/src/dev/build/tasks/copy_translations_task.ts new file mode 100644 index 000000000000..112224bcddf8 --- /dev/null +++ b/src/dev/build/tasks/copy_translations_task.ts @@ -0,0 +1,51 @@ +/* + * Copyright OpenSearch Contributors + * SPDX-License-Identifier: Apache-2.0 + */ + +import { i18nLoader } from '@osd/i18n'; +import { write, Task } from '../lib'; +import { getTranslationPaths } from '../../../legacy/server/i18n/get_translations_path'; +import { I18N_RC, DEFAULT_DIRS_WITH_RC_FILES } from '../../i18n/constants'; + +const TRANSLATIONS_PATH = 'i18n'; + +export const CopyTranslations: Task = { + description: 'Copying translations into platform-generic build directory', + + async run(config, log, build) { + const repoRoot = config.resolveFromRepo(); + + log.info('Gathering translations'); + + const allTranslationPaths = await getTranslationPaths({ + cwd: repoRoot, + // `,.` is added for backward compatibility + // ToDo: Remove `,.` for next major release + glob: `{${DEFAULT_DIRS_WITH_RC_FILES.join(',')},.}/${I18N_RC}`, + }); + + i18nLoader.registerTranslationFiles(allTranslationPaths); + + log.info('Combining translations'); + + const translationFiles: string[] = []; + + for (const locale of i18nLoader.getRegisteredLocales()) { + const { formats, messages } = await i18nLoader.getTranslationsByLocale(locale); + const translationFilename = `${locale}.json`; + translationFiles.push(translationFilename); + await write( + build.resolvePath(`${TRANSLATIONS_PATH}/${translationFilename}`), + JSON.stringify({ formats, messages }) + ); + } + + log.info('Generating translation manifest'); + + await write( + build.resolvePath(`${TRANSLATIONS_PATH}/${I18N_RC}`), + JSON.stringify({ translations: translationFiles }) + ); + }, +}; diff --git a/src/dev/build/tasks/index.ts b/src/dev/build/tasks/index.ts index f6b7a2d6726d..28399f9cb702 100644 --- a/src/dev/build/tasks/index.ts +++ b/src/dev/build/tasks/index.ts @@ -33,6 +33,7 @@ export * from './build_opensearch_dashboards_platform_plugins'; export * from './build_packages_task'; export * from './clean_tasks'; export * from './copy_source_task'; +export * from './copy_translations_task'; export * from './create_archives_sources_task'; export * from './create_archives_task'; export * from './create_empty_dirs_and_files_task'; diff --git a/src/dev/i18n/config.ts b/src/dev/i18n/config.ts index 03b41ca7886f..2430517558d9 100644 --- a/src/dev/i18n/config.ts +++ b/src/dev/i18n/config.ts @@ -28,10 +28,10 @@ * under the License. */ -import { resolve } from 'path'; +import { resolve, dirname } from 'path'; // @ts-ignore -import { normalizePath, readFileAsync } from '.'; +import { normalizePath, readFileAsync, accessAsync } from '.'; export interface I18nConfig { paths: Record; @@ -40,7 +40,19 @@ export interface I18nConfig { prefix?: string; } -export async function checkConfigNamespacePrefix(configPath: string) { +export async function checkConfigNamespacePrefix( + configPath: string, + failOnNotFound: boolean = true +) { + if (failOnNotFound === false) { + try { + await accessAsync(resolve(configPath)); + } catch (ex) { + // If the file doesn't exist, return silently + return; + } + } + const { prefix, paths } = JSON.parse(await readFileAsync(resolve(configPath))); for (const [namespace] of Object.entries(paths)) { if (prefix && prefix !== namespace.split('.')[0]) { @@ -51,8 +63,18 @@ export async function checkConfigNamespacePrefix(configPath: string) { export async function assignConfigFromPath( config: I18nConfig = { exclude: [], translations: [], paths: {} }, - configPath: string + configPath: string, + failOnNotFound: boolean = true ) { + if (failOnNotFound === false) { + try { + await accessAsync(resolve(configPath)); + } catch (ex) { + // If the file doesn't exist, return the untouched config + return config; + } + } + const additionalConfig: I18nConfig = { paths: {}, exclude: [], @@ -60,17 +82,19 @@ export async function assignConfigFromPath( ...JSON.parse(await readFileAsync(resolve(configPath))), }; + const configDirName = dirname(configPath); + for (const [namespace, namespacePaths] of Object.entries(additionalConfig.paths)) { const paths = Array.isArray(namespacePaths) ? namespacePaths : [namespacePaths]; - config.paths[namespace] = paths.map((path) => normalizePath(resolve(configPath, '..', path))); + config.paths[namespace] = paths.map((path) => normalizePath(resolve(configDirName, path))); } for (const exclude of additionalConfig.exclude) { - config.exclude.push(normalizePath(resolve(configPath, '..', exclude))); + config.exclude.push(normalizePath(resolve(configDirName, exclude))); } for (const translations of additionalConfig.translations) { - config.translations.push(normalizePath(resolve(configPath, '..', translations))); + config.translations.push(normalizePath(resolve(configDirName, translations))); } return config; diff --git a/src/dev/i18n/constants.ts b/src/dev/i18n/constants.ts index adbf5cde98e1..9fd2c031b622 100644 --- a/src/dev/i18n/constants.ts +++ b/src/dev/i18n/constants.ts @@ -32,3 +32,6 @@ export const DEFAULT_MESSAGE_KEY = 'defaultMessage'; export const DESCRIPTION_KEY = 'description'; export const VALUES_KEY = 'values'; export const I18N_RC = '.i18nrc.json'; + +// ToDo: Recursively look for I18N_RC in these 3 locations +export const DEFAULT_DIRS_WITH_RC_FILES: string[] = ['src', 'examples', 'packages']; diff --git a/src/dev/i18n/index.ts b/src/dev/i18n/index.ts index 8b5f67d03e81..c59bee6fcb8d 100644 --- a/src/dev/i18n/index.ts +++ b/src/dev/i18n/index.ts @@ -32,7 +32,14 @@ export { extractMessagesFromPathToMap } from './extract_default_translations'; // @ts-ignore export { matchEntriesWithExctractors } from './extract_default_translations'; -export { arrayify, writeFileAsync, readFileAsync, normalizePath, ErrorReporter } from './utils'; +export { + arrayify, + writeFileAsync, + readFileAsync, + accessAsync, + normalizePath, + ErrorReporter, +} from './utils'; export { serializeToJson, serializeToJson5 } from './serializers'; export { I18nConfig, diff --git a/src/dev/i18n/tasks/check_configs.ts b/src/dev/i18n/tasks/check_configs.ts index 2e37a5e00cf0..0c7f13c4c9a6 100644 --- a/src/dev/i18n/tasks/check_configs.ts +++ b/src/dev/i18n/tasks/check_configs.ts @@ -29,19 +29,23 @@ */ import { resolve, join } from 'path'; import { ListrContext } from '.'; -import { I18N_RC } from '../constants'; +import { DEFAULT_DIRS_WITH_RC_FILES, I18N_RC } from '../constants'; import { checkConfigNamespacePrefix, arrayify } from '..'; export function checkConfigs(additionalConfigPaths: string | string[] = []) { const root = join(__dirname, '../../../../'); + const defaultRCs = DEFAULT_DIRS_WITH_RC_FILES.map((value) => resolve(root, value, I18N_RC)); + + // For backward compatibility + // ToDo: Remove for next major release const opensearchDashboardsRC = resolve(root, I18N_RC); - const configPaths = [opensearchDashboardsRC, ...arrayify(additionalConfigPaths)]; + const configPaths = [opensearchDashboardsRC, ...defaultRCs, ...arrayify(additionalConfigPaths)]; return configPaths.map((configPath) => ({ task: async (context: ListrContext) => { try { - await checkConfigNamespacePrefix(configPath); + await checkConfigNamespacePrefix(configPath, false); } catch (err) { const { reporter } = context; const reporterWithContext = reporter.withContext({ name: configPath }); diff --git a/src/dev/i18n/tasks/merge_configs.ts b/src/dev/i18n/tasks/merge_configs.ts index 79c1fde91e95..7687dce2abd0 100644 --- a/src/dev/i18n/tasks/merge_configs.ts +++ b/src/dev/i18n/tasks/merge_configs.ts @@ -30,17 +30,22 @@ import { resolve, join } from 'path'; import { ListrContext } from '.'; import { assignConfigFromPath, arrayify } from '..'; +import { DEFAULT_DIRS_WITH_RC_FILES, I18N_RC } from '../constants'; export function mergeConfigs(additionalConfigPaths: string | string[] = []) { const root = join(__dirname, '../../../../'); - const opensearchDashboardsRC = resolve(root, '.i18nrc.json'); + const defaultRCs = DEFAULT_DIRS_WITH_RC_FILES.map((value) => resolve(root, value, I18N_RC)); - const configPaths = [opensearchDashboardsRC, ...arrayify(additionalConfigPaths)]; + // For backward compatibility + // ToDo: Remove for next major release + const opensearchDashboardsRC = resolve(root, I18N_RC); + + const configPaths = [opensearchDashboardsRC, ...defaultRCs, ...arrayify(additionalConfigPaths)]; return configPaths.map((configPath) => ({ task: async (context: ListrContext) => { try { - context.config = await assignConfigFromPath(context.config, configPath); + context.config = await assignConfigFromPath(context.config, configPath, false); } catch (err) { const { reporter } = context; const reporterWithContext = reporter.withContext({ name: configPath }); diff --git a/src/dev/run_i18n_check.ts b/src/dev/run_i18n_check.ts index 17fc397a7bf1..08ff3a6f09b1 100644 --- a/src/dev/run_i18n_check.ts +++ b/src/dev/run_i18n_check.ts @@ -41,6 +41,7 @@ import { mergeConfigs, ListrContext, } from './i18n/tasks'; +import { DEFAULT_DIRS_WITH_RC_FILES } from './i18n/constants'; const skipOnNoTranslations = (context: ListrContext) => !context.config?.translations?.length && 'No translations found.'; @@ -83,7 +84,7 @@ run( throw createFailError(`${chalk.white.bgRed(' I18N ERROR ')} --fix can't have a value`); } - const srcPaths = Array().concat(path || ['./src', './packages']); + const srcPaths = Array().concat(path || DEFAULT_DIRS_WITH_RC_FILES); const list = new Listr( [ @@ -104,7 +105,6 @@ run( }, { title: 'Validating Default Messages', - skip: skipOnNoTranslations, task: ({ config }) => { return new Listr(extractDefaultMessages(config, srcPaths), { exitOnError: true }); }, diff --git a/src/dev/run_i18n_extract.ts b/src/dev/run_i18n_extract.ts index 6de6b0904abb..abe7dcc4a3c3 100644 --- a/src/dev/run_i18n_extract.ts +++ b/src/dev/run_i18n_extract.ts @@ -35,6 +35,7 @@ import { resolve } from 'path'; import { createFailError, run } from '@osd/dev-utils'; import { ErrorReporter, serializeToJson, serializeToJson5, writeFileAsync } from './i18n'; import { extractDefaultMessages, mergeConfigs, ListrContext } from './i18n/tasks'; +import { DEFAULT_DIRS_WITH_RC_FILES } from './i18n/constants'; run( async ({ @@ -57,7 +58,7 @@ run( `${chalk.white.bgRed(' I18N ERROR ')} --path and --include-config require a value` ); } - const srcPaths = Array().concat(path || ['./src', './packages']); + const srcPaths = Array().concat(path || DEFAULT_DIRS_WITH_RC_FILES); const list = new Listr([ { diff --git a/src/dev/run_i18n_integrate.ts b/src/dev/run_i18n_integrate.ts index 6f0314e757e2..4a11c5b79214 100644 --- a/src/dev/run_i18n_integrate.ts +++ b/src/dev/run_i18n_integrate.ts @@ -34,6 +34,7 @@ import Listr from 'listr'; import { createFailError, run } from '@osd/dev-utils'; import { ErrorReporter, integrateLocaleFiles } from './i18n'; import { extractDefaultMessages, mergeConfigs, ListrContext } from './i18n/tasks'; +import { DEFAULT_DIRS_WITH_RC_FILES } from './i18n/constants'; run( async ({ @@ -88,7 +89,7 @@ run( ); } - const srcPaths = Array().concat(path || ['./src', './packages']); + const srcPaths = Array().concat(path || DEFAULT_DIRS_WITH_RC_FILES); const list = new Listr([ { diff --git a/src/legacy/server/i18n/index.ts b/src/legacy/server/i18n/index.ts index 8a571144cdf5..f82822b7a672 100644 --- a/src/legacy/server/i18n/index.ts +++ b/src/legacy/server/i18n/index.ts @@ -29,7 +29,6 @@ */ import { i18n, i18nLoader } from '@osd/i18n'; -import { basename } from 'path'; import { Server } from '@hapi/hapi'; import { fromRoot } from '../../../core/server/utils'; import type { UsageCollectionSetup } from '../../../plugins/usage_collection/server'; diff --git a/src/plugins/data_explorer/.i18nrc.json b/src/plugins/data_explorer/.i18nrc.json deleted file mode 100644 index 1ea4ccdd1e7b..000000000000 --- a/src/plugins/data_explorer/.i18nrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "prefix": "dataExplorer", - "paths": { - "dataExplorer": "." - }, - "translations": ["translations/ja-JP.json"] -} diff --git a/src/plugins/query_enhancements/.i18nrc.json b/src/plugins/query_enhancements/.i18nrc.json deleted file mode 100644 index bb9a3ef5e506..000000000000 --- a/src/plugins/query_enhancements/.i18nrc.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "prefix": "queryEnhancements", - "paths": { - "queryEnhancements": "." - }, - "translations": ["translations/ja-JP.json"] -}