Merge "codex: Provide i18n function and messages"

This commit is contained in:
jenkins-bot 2024-07-03 07:06:47 +00:00 committed by Gerrit Code Review
commit cdfdbfb1c9
4 changed files with 19 additions and 0 deletions

View file

@ -61,6 +61,7 @@ module.exports = function ( grunt ) {
disallowBlankTranslations: false
},
core: 'languages/i18n/',
codex: 'languages/i18n/codex/',
exif: 'languages/i18n/exif/',
preferences: 'languages/i18n/preferences/',
api: 'includes/api/i18n/',

View file

@ -127,6 +127,21 @@ class CodexModule extends FileModule {
) );
}
// Add messages used inside Codex Vue components.
if ( isset( $options['codexFullLibrary'] ) || ( !$this->isStyleOnly && count( $this->codexComponents ) > 0 ) ) {
$options[ 'messages' ] = array_merge( $options[ 'messages' ] ?? [], [
'cdx-input-chip-aria-description',
'cdx-dialog-close-button-label',
'cdx-label-optional-flag',
'cdx-message-dismiss-button-label',
'cdx-search-input-search-button-label',
'cdx-table-select-all-label',
'cdx-table-select-row-label',
'cdx-table-sort-caption',
'cdx-typeahead-search-search-results-label',
] );
}
if ( in_array( '@wikimedia/codex', $options[ 'dependencies' ] ) ) {
throw new InvalidArgumentException(
'ResourceLoader modules using the CodexModule class cannot ' .

View file

@ -965,6 +965,7 @@ class LocalisationCache {
return [
'core' => "$IP/languages/i18n",
'codex' => "$IP/languages/i18n/codex",
'exif' => "$IP/languages/i18n/exif",
'preferences' => "$IP/languages/i18n/preferences",
'api' => "$IP/includes/api/i18n",

View file

@ -31,6 +31,8 @@
app.use( errorLogger );
app.use( i18n );
app.provide( 'CdxTeleportTarget', teleportTarget );
// Includes all messages with `cdx-` prefix in languages/i18n/codex.
app.provide( 'CdxI18nFunction', mw.msg );
return app;
};