Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions dist/microbitMore.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5039,8 +5039,20 @@ var formatMessage = function formatMessage(messageData) {
*/
var setupTranslations = function setupTranslations() {
var localeSetup = formatMessage.setup();
if (localeSetup && localeSetup.translations[localeSetup.locale]) {
Object.assign(localeSetup.translations[localeSetup.locale], translations[localeSetup.locale]);
if (!localeSetup) return;

var currentLocale = localeSetup.locale;
if (!currentLocale) return;

// Try exact match first, then fall back to base locale (e.g., 'de-DE' -> 'de')
var baseLocale = currentLocale.split('-')[0].split('_')[0];
var translationKey = translations[currentLocale] ? currentLocale : null;
if (!translationKey && baseLocale !== currentLocale) {
translationKey = translations[baseLocale] ? baseLocale : null;
}

if (localeSetup.translations[currentLocale] && translationKey) {
Object.assign(localeSetup.translations[currentLocale], translations[translationKey]);
}
};
var EXTENSION_ID = 'microbitMore';
Expand Down
18 changes: 15 additions & 3 deletions src/vm/extensions/block/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,22 @@ let formatMessage = messageData => messageData.defaultMessage;
*/
const setupTranslations = () => {
const localeSetup = formatMessage.setup();
if (localeSetup && localeSetup.translations[localeSetup.locale]) {
if (!localeSetup) return;

const currentLocale = localeSetup.locale;
if (!currentLocale) return;

// Try exact match first, then fall back to base locale (e.g., 'de-DE' -> 'de')
const baseLocale = currentLocale.split('-')[0].split('_')[0];
let translationKey = translations[currentLocale] ? currentLocale : null;
if (!translationKey && baseLocale !== currentLocale) {
translationKey = translations[baseLocale] ? baseLocale : null;
}

if (localeSetup.translations[currentLocale] && translationKey) {
Object.assign(
localeSetup.translations[localeSetup.locale],
translations[localeSetup.locale]
localeSetup.translations[currentLocale],
translations[translationKey]
);
}
};
Expand Down