-
Notifications
You must be signed in to change notification settings - Fork 916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split .i18nrc across src
, packages
, and examples
#8414
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"paths": { | ||
"embeddableExamples": "embeddable_examples", | ||
"expressionsExample": "expressions_example", | ||
"multipleDataSourceExample": "multiple_data_source_examples", | ||
"searchExamples": "search_examples", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the difference in total number of paths across these .i18nrc.json files due to adding some that were not added to the original ones? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. |
||
"stateContainerExamples": "state_containers_examples", | ||
"uiActionsExamples": "ui_action_examples", | ||
"uiActionsExplorer": "ui_actions_explorer" | ||
}, | ||
"translations": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"paths": { | ||
"flot": "osd-ui-shared-deps/flot_charts" | ||
}, | ||
"translations": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
} | ||
Comment on lines
+75
to
+78
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice! |
||
await run(Tasks.CopyBinScripts); | ||
await run(Tasks.CreateEmptyDirsAndFiles); | ||
await run(Tasks.CreateReadme); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 }) | ||
); | ||
}, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if i create a new example or core or external plugin, how will this be updated? I think one of the reasons for keeping the i18nrc file in each plugin migt have been to make scaffolding easier (just speculation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Each external plugin will continue to own its own i18n manifest and translations. Each internal plugin, package, or example will eventually have their own manifest too, but with this PR, each will use the translations from the
src
,packages
, orexamples
. Prior to this PR, they all had to pick from one central place.There is logic which I think "imports" translations files and distributes them to the folder of each manifest based on the namesspaces defined in them. All of these will tie into each other when and if I get to next phase.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you document this in a rewadme as a part of the change so that:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A readme would be helpful - I really don't know how this works so harder to review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have https://github.com/opensearch-project/dashboards-i18n/blob/main/DEVELOPER_GUIDE.md and https://github.com/opensearch-project/OpenSearch-Dashboards/tree/main/packages/osd-i18n. Some day, I will merge those into one and add my future vision into it.