-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
migrate i18n mixin to KP #81799
migrate i18n mixin to KP #81799
Conversation
// do not try to shorten the import to `./status`, it will break server test mocking | ||
import { StatusService } from './status/status_service'; |
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.
TIL, after loosing 1h on that...
"type": "long" | ||
} | ||
} | ||
} | ||
} | ||
"properties": {} | ||
} |
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.
@elastic/kibana-telemetry This PR removes the last legacy usage collector. I guess this file and the generation / usage around it could now be safely deleted I guess. Not sure if it is trivial enough to be done in current PR though. Would it be fine to let you handle that in a follow-up?
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'd have to update the .telemetryrc.json
file and it will automatically be removed. We can push that change in another PR
src/core/server/i18n/i18n_service.ts
Outdated
getLocale(): string; | ||
|
||
/** | ||
* Return the list of translation files currently in use. | ||
*/ | ||
getTranslationFiles(): string[]; |
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.
I need that to be accessible for the localization
usage collector.
The getLocale
is not really necessary as the collector could use i18n.getLocale()
instead, but from an architectural point of view, I think it is better to have core be the entry point for that (and the contract is needed anyway for getTranslationFiles
so it did not cost much to also add an additional API to it)
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.
According to our classification, @kbn/i18n
should be implemented as a service because it's a stateful package. IIRC we were discussing to deprecate direct access to @kbn/i18n
in favour of i18n
Platform service, so 👍
getTranslationPaths({ | ||
cwd: fromRoot('.'), | ||
glob: `*/${I18N_RC}`, | ||
nested: true, | ||
}), |
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.
AFAIK, this is only used to get the x-pack/.i18nrc.json
file. However to avoid any risk / breaking changes (User could have custom i18nrc files in another non-plugin folder eventually), I kept it as it was done in legacy.
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.
@pgayvallet only in x-pack
. I believe it is safe to change it as long as x-pack
and kibana's root dir are discoverable.
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.
does it mean that it traverses all the node_modules
and other unnecessary folders?
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.
No. */something
globbing is only scanning a single level (as opposed to **/something
)
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.
ok, I didn't check implementation. but nested: true
traversing on a single level in-depth is confusing 😅
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.
Yea, you're right. I kinda wanted to rename it to includeSubFolders
, but is was way longer, and not really more explicit that we are only scanning one level down. No issue renaming if you have a better idea.
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 will need something similar to maxScanDepth
in discovery to support migration to Domain-based folder structure. But I'm okay to keep it as is for now.
getTranslationPaths({ | ||
cwd: fromRoot('../kibana-extra'), | ||
glob: `*/${I18N_RC}`, | ||
nested: true, | ||
}), |
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.
Are we really still using kibana-extra
? Kept that, but not sure if it is really necessary.
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.
As long as we still support running plugins from that path then we should keep it. If not there is no need to.
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 still search for a plugin in kibana-extra
resolve(rootDir, '..', 'kibana-extra'), |
kbn-pm
supports it as well https://github.com/elastic/kibana/blob/0068c87d6fe7713351acbf42080faa09ff73ef15/packages/kbn-pm/README.mdBut I haven't checked whether it works
...(config.get('plugins.paths') as string[]).map((cwd) => | ||
getTranslationPaths({ cwd, glob: I18N_RC }) | ||
), | ||
...(config.get('plugins.scanDirs') as string[]).map((cwd) => | ||
getTranslationPaths({ cwd, glob: `*/${I18N_RC}` }) | ||
), | ||
...pluginPaths.map((pluginPath) => getTranslationPaths({ cwd: pluginPath, nested: false })), |
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.
There is a slight change of behavior here:
Legacy was just reading the plugin config and scanning the scanDirs
(1 lvl deep) and paths
(root lvl) for i18n rc files.
I chose to change that by retrieving the list of enabled plugins from the plugin service, and check if there is a i18n file at the root level of each plugin instead. This is basically the same, except that we are not loading translation files for disabled plugins (note that this only concerns 3rd parties plugin, as kibana translations are all defined from a single x-pack/.i18nrc.json
file anyway). Overall, I think it should not really impact 3rd parties, and not loading translations for disabled plugins does make sense imho. (This is also way better at the code level in term of responsibilities per service. I was really awkward to load the plugins
config from the i18n
service)
Pinging @elastic/kibana-platform (Team:Platform) |
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.
Telemetry changes LGTM!
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.
LGTM! Thanks
getTranslationPaths({ | ||
cwd: fromRoot('.'), | ||
glob: `*/${I18N_RC}`, | ||
nested: true, | ||
}), |
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.
@pgayvallet only in x-pack
. I believe it is safe to change it as long as x-pack
and kibana's root dir are discoverable.
getTranslationPaths({ | ||
cwd: fromRoot('../kibana-extra'), | ||
glob: `*/${I18N_RC}`, | ||
nested: true, | ||
}), |
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.
As long as we still support running plugins from that path then we should keep it. If not there is no need to.
"type": "long" | ||
} | ||
} | ||
} | ||
} | ||
"properties": {} | ||
} |
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'd have to update the .telemetryrc.json
file and it will automatically be removed. We can push that change in another PR
docs/development/core/server/kibana-plugin-core-server.i18nservicesetup.gettranslationfiles.md
Show resolved
Hide resolved
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.
I'd like to adjust #81799 (comment) if necessary. Otherwise looks good
💚 Build SucceededMetrics [docs]Distributable file count
History
To update your PR or re-run it, just comment with: |
* migrate i18n mixin to KP * directly load the config from i18n service * add base tests * update telemetry schema * update legacy telemetry schema * fix server tests * use paths from config service instead of manually loading the plugin config * add tests for get_translation_paths * add tests for i18n service * add plugin service test * update generated doc * improve tsdoc
* migrate i18n mixin to KP * directly load the config from i18n service * add base tests * update telemetry schema * update legacy telemetry schema * fix server tests * use paths from config service instead of manually loading the plugin config * add tests for get_translation_paths * add tests for i18n service * add plugin service test * update generated doc * improve tsdoc
…kibana into bootstrap-node-details-overlay * 'bootstrap-node-details-overlay' of github.com:phillipb/kibana: (49 commits) [Security Solution] Fix DNS Network table query (elastic#82778) [Workplace Search] Consolidate groups routes (elastic#83015) Adds cloud links to user menu (elastic#82803) [Security Solution][Detections] - follow up cleanup on auto refresh rules (elastic#83023) [App Search] Added the log retention panel to the Settings page (elastic#82982) [Maps] show icon when layer is filtered by time and allow layers to ignore global time range (elastic#83006) [DOCS] Consolidates drilldown pages (elastic#82081) [Maps] add on-prem EMS config (elastic#82525) migrate i18n mixin to KP (elastic#81799) [bundle optimization] fix imports of react-use lib (elastic#82847) [Discover] Add metric on adding filter (elastic#82961) [Lens] Performance refactoring for indexpattern fast lookup and Operation support matrix computation (elastic#82829) skip flaky suite (elastic#82804) Fix SO query for searching across spaces (elastic#83025) renaming built-in alerts to Stack Alerts (elastic#82873) [TSVB] Disable using top_hits in pipeline aggregations (elastic#82278) [Visualizations] Remove kui usage (elastic#82810) [Visualizations] Make the icon buttons labels more descriptive (elastic#82585) [Lens] Do not reset formatting when switching between custom ranges and auto histogram (elastic#82694) Fix ilm navigation (elastic#81664) ...
…na into alerts/stack-alerts-public * 'alerts/stack-alerts-public' of github.com:gmmorris/kibana: [Security Solution] Fix DNS Network table query (elastic#82778) [Workplace Search] Consolidate groups routes (elastic#83015) Adds cloud links to user menu (elastic#82803) [Security Solution][Detections] - follow up cleanup on auto refresh rules (elastic#83023) [App Search] Added the log retention panel to the Settings page (elastic#82982) [Maps] show icon when layer is filtered by time and allow layers to ignore global time range (elastic#83006) [DOCS] Consolidates drilldown pages (elastic#82081) [Maps] add on-prem EMS config (elastic#82525) migrate i18n mixin to KP (elastic#81799) [bundle optimization] fix imports of react-use lib (elastic#82847) [Discover] Add metric on adding filter (elastic#82961) [Lens] Performance refactoring for indexpattern fast lookup and Operation support matrix computation (elastic#82829) skip flaky suite (elastic#82804) Fix SO query for searching across spaces (elastic#83025) renaming built-in alerts to Stack Alerts (elastic#82873) [TSVB] Disable using top_hits in pipeline aggregations (elastic#82278) [Visualizations] Remove kui usage (elastic#82810) [Visualizations] Make the icon buttons labels more descriptive (elastic#82585) [Lens] Do not reset formatting when switching between custom ranges and auto histogram (elastic#82694) :
Summary
Fix #50647
Migrate i18n loading to
core
.i18n
serviceLocalization
usage collector to thekibana_usage_collection
pluginChecklist