@yunsoft/yuncms-core 0.1.18 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/bootstrap.js
CHANGED
|
@@ -19,6 +19,7 @@ import { navigationGroupCollapseMigration } from './migrations/0016-navigation-g
|
|
|
19
19
|
import { mcpSettingsMigration } from './migrations/0017-mcp-settings.js';
|
|
20
20
|
import { publicRegistrationSettingsMigration } from './migrations/0018-public-registration-settings.js';
|
|
21
21
|
import { publicRegistrationEmailVerificationMigration } from './migrations/0019-public-registration-email-verification.js';
|
|
22
|
+
import { studioLocalesMigration } from './migrations/0020-studio-locales.js';
|
|
22
23
|
import { readSchemaVersion } from './schema-version.js';
|
|
23
24
|
import { ensurePublicRole } from './setup.js';
|
|
24
25
|
|
|
@@ -42,6 +43,7 @@ export const CORE_MIGRATIONS = Object.freeze([
|
|
|
42
43
|
mcpSettingsMigration,
|
|
43
44
|
publicRegistrationSettingsMigration,
|
|
44
45
|
publicRegistrationEmailVerificationMigration,
|
|
46
|
+
studioLocalesMigration,
|
|
45
47
|
]);
|
|
46
48
|
|
|
47
49
|
export const REQUIRED_CORE_MIGRATION_IDS = Object.freeze(
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const studioLocalesMigration = {
|
|
2
|
+
id: '0020-studio-locales',
|
|
3
|
+
statements: [
|
|
4
|
+
`ALTER TABLE yuncms_studio_settings
|
|
5
|
+
DROP CHECK chk_yuncms_studio_settings_locale,
|
|
6
|
+
ADD CONSTRAINT chk_yuncms_studio_settings_locale
|
|
7
|
+
CHECK (default_locale IN ('en', 'tr', 'es', 'de', 'fr', 'pt-BR', 'ja', 'zh-CN'))`,
|
|
8
|
+
],
|
|
9
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { canonicalStudioLocale, STUDIO_LOCALE_CODES } from '../studio-locales.js';
|
|
1
2
|
import { BaseService } from './base-service.js';
|
|
2
3
|
|
|
3
4
|
const THEMES = new Set(['system', 'light', 'dark']);
|
|
4
|
-
const LOCALES = new Set(['en', 'tr']);
|
|
5
5
|
const ACCENT_PATTERN = /^#[0-9a-f]{6}$/i;
|
|
6
6
|
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
|
|
7
7
|
const YUNSOFT_LOGOS = new Set([
|
|
@@ -63,8 +63,10 @@ function normalizeTheme(value) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
function normalizeLocale(value) {
|
|
66
|
-
const normalized =
|
|
67
|
-
if (!
|
|
66
|
+
const normalized = canonicalStudioLocale(value);
|
|
67
|
+
if (!normalized) {
|
|
68
|
+
throw invalid(`Default locale must be one of: ${STUDIO_LOCALE_CODES.join(', ')}`);
|
|
69
|
+
}
|
|
68
70
|
return normalized;
|
|
69
71
|
}
|
|
70
72
|
|
|
@@ -293,4 +295,4 @@ export const STUDIO_SETTING_DEFAULTS = Object.freeze({
|
|
|
293
295
|
public_registration_enabled: false,
|
|
294
296
|
public_registration_role: null,
|
|
295
297
|
public_registration_require_email_verification: false,
|
|
296
|
-
});
|
|
298
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const STUDIO_LOCALE_CODES = Object.freeze(['en', 'tr', 'es', 'de', 'fr', 'pt-BR', 'ja', 'zh-CN']);
|
|
2
|
+
|
|
3
|
+
const STUDIO_LOCALE_LOOKUP = new Map(
|
|
4
|
+
STUDIO_LOCALE_CODES.map((locale) => [locale.toLowerCase(), locale]),
|
|
5
|
+
);
|
|
6
|
+
|
|
7
|
+
export function canonicalStudioLocale(value) {
|
|
8
|
+
return STUDIO_LOCALE_LOOKUP.get(String(value ?? '').trim().toLowerCase()) ?? null;
|
|
9
|
+
}
|