@playcraft/adsdk 1.0.17 → 1.0.18-beta.2
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/LICENSE +21 -21
- package/defines.d.ts +130 -130
- package/dist/esm/index.js +249 -2
- package/dist/iife/index.js +247 -2
- package/dist/index.d.mts +63 -2
- package/dist/index.d.ts +63 -2
- package/dist/index.js +251 -2
- package/package.json +56 -56
package/dist/iife/index.js
CHANGED
|
@@ -681,6 +681,196 @@
|
|
|
681
681
|
}
|
|
682
682
|
}
|
|
683
683
|
|
|
684
|
+
// src/language.ts
|
|
685
|
+
function readQuerystring(key) {
|
|
686
|
+
try {
|
|
687
|
+
if (typeof window === "undefined" || !window.location) return void 0;
|
|
688
|
+
const search = window.location.search || "";
|
|
689
|
+
if (!search) return void 0;
|
|
690
|
+
if (typeof URLSearchParams !== "undefined") {
|
|
691
|
+
const params = new URLSearchParams(search);
|
|
692
|
+
return params.get(key) || void 0;
|
|
693
|
+
}
|
|
694
|
+
const re = new RegExp("[?&]" + key.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^&#]*)");
|
|
695
|
+
const m = re.exec(search);
|
|
696
|
+
return m ? decodeURIComponent(m[1]) : void 0;
|
|
697
|
+
} catch (e) {
|
|
698
|
+
return void 0;
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
function readLocalStorage(key) {
|
|
702
|
+
try {
|
|
703
|
+
if (typeof localStorage === "undefined") return void 0;
|
|
704
|
+
return localStorage.getItem(key) || void 0;
|
|
705
|
+
} catch (e) {
|
|
706
|
+
return void 0;
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
function readCookie(name) {
|
|
710
|
+
try {
|
|
711
|
+
if (typeof document === "undefined" || !document.cookie) return void 0;
|
|
712
|
+
const re = new RegExp("(?:^|; )" + name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&") + "=([^;]*)");
|
|
713
|
+
const m = re.exec(document.cookie);
|
|
714
|
+
return m ? decodeURIComponent(m[1]) : void 0;
|
|
715
|
+
} catch (e) {
|
|
716
|
+
return void 0;
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
function readNavigatorLanguages() {
|
|
720
|
+
try {
|
|
721
|
+
if (typeof navigator === "undefined") return [];
|
|
722
|
+
const list = [];
|
|
723
|
+
const langs = navigator.languages;
|
|
724
|
+
if (Array.isArray(langs)) list.push(...langs);
|
|
725
|
+
if (navigator.language) list.push(navigator.language);
|
|
726
|
+
const userLang = navigator.userLanguage || navigator.browserLanguage;
|
|
727
|
+
if (userLang) list.push(userLang);
|
|
728
|
+
return list.filter(Boolean);
|
|
729
|
+
} catch (e) {
|
|
730
|
+
return [];
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
function readHtmlTag() {
|
|
734
|
+
try {
|
|
735
|
+
if (typeof document === "undefined" || !document.documentElement) return void 0;
|
|
736
|
+
return document.documentElement.lang || void 0;
|
|
737
|
+
} catch (e) {
|
|
738
|
+
return void 0;
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
function detectCandidates() {
|
|
742
|
+
return [
|
|
743
|
+
readQuerystring("lng"),
|
|
744
|
+
readLocalStorage("i18nextLng"),
|
|
745
|
+
readCookie("i18next"),
|
|
746
|
+
...readNavigatorLanguages(),
|
|
747
|
+
readHtmlTag()
|
|
748
|
+
];
|
|
749
|
+
}
|
|
750
|
+
var SUPPORTED_LANG_CODES = [
|
|
751
|
+
"en",
|
|
752
|
+
"zh",
|
|
753
|
+
"ja",
|
|
754
|
+
"ko",
|
|
755
|
+
"de",
|
|
756
|
+
"fr",
|
|
757
|
+
"es",
|
|
758
|
+
"pt",
|
|
759
|
+
"it",
|
|
760
|
+
"hi",
|
|
761
|
+
"bn",
|
|
762
|
+
"ur",
|
|
763
|
+
"ar",
|
|
764
|
+
"tr",
|
|
765
|
+
"ru",
|
|
766
|
+
"ms",
|
|
767
|
+
"id"
|
|
768
|
+
];
|
|
769
|
+
function normalizeLangTag(tag) {
|
|
770
|
+
if (!tag || typeof tag !== "string") return void 0;
|
|
771
|
+
const primary = tag.split(/[-_]/)[0].toLowerCase();
|
|
772
|
+
return SUPPORTED_LANG_CODES.indexOf(primary) >= 0 ? primary : void 0;
|
|
773
|
+
}
|
|
774
|
+
function getLanguageCode() {
|
|
775
|
+
const candidates = detectCandidates();
|
|
776
|
+
for (const tag of candidates) {
|
|
777
|
+
const code = normalizeLangTag(tag);
|
|
778
|
+
if (code) return code;
|
|
779
|
+
}
|
|
780
|
+
return "en";
|
|
781
|
+
}
|
|
782
|
+
var LANGUAGE_MAP = {
|
|
783
|
+
// 英语
|
|
784
|
+
"en": "EN",
|
|
785
|
+
// 中文(简体)
|
|
786
|
+
"zh": "CN_S",
|
|
787
|
+
"zh-cn": "CN_S",
|
|
788
|
+
"zh-sg": "CN_S",
|
|
789
|
+
"zh-my": "CN_S",
|
|
790
|
+
"zh-hans": "CN_S",
|
|
791
|
+
"zh-hans-cn": "CN_S",
|
|
792
|
+
"zh-hans-sg": "CN_S",
|
|
793
|
+
"zh-hans-my": "CN_S",
|
|
794
|
+
// 中文(繁体)
|
|
795
|
+
"zh-tw": "CN_T",
|
|
796
|
+
"zh-hk": "CN_T",
|
|
797
|
+
"zh-mo": "CN_T",
|
|
798
|
+
"zh-hant": "CN_T",
|
|
799
|
+
"zh-hant-tw": "CN_T",
|
|
800
|
+
"zh-hant-hk": "CN_T",
|
|
801
|
+
"zh-hant-mo": "CN_T",
|
|
802
|
+
// 德语
|
|
803
|
+
"de": "DE",
|
|
804
|
+
// 法语
|
|
805
|
+
"fr": "FR",
|
|
806
|
+
// 西班牙语
|
|
807
|
+
"es": "ES",
|
|
808
|
+
// 日语
|
|
809
|
+
"ja": "JA",
|
|
810
|
+
// 韩语
|
|
811
|
+
"ko": "KO",
|
|
812
|
+
// 葡萄牙语
|
|
813
|
+
"pt": "PT",
|
|
814
|
+
// 意大利语
|
|
815
|
+
"it": "IT",
|
|
816
|
+
// 印地语
|
|
817
|
+
"hi": "HI",
|
|
818
|
+
// 孟加拉语
|
|
819
|
+
"bn": "BN",
|
|
820
|
+
// 乌尔都语
|
|
821
|
+
"ur": "UR",
|
|
822
|
+
// 阿拉伯语
|
|
823
|
+
"ar": "AR",
|
|
824
|
+
// 土耳其语
|
|
825
|
+
"tr": "TR",
|
|
826
|
+
// 俄语
|
|
827
|
+
"ru": "RU",
|
|
828
|
+
// 马来语
|
|
829
|
+
"ms": "MS",
|
|
830
|
+
// 印尼语
|
|
831
|
+
"id": "ID"
|
|
832
|
+
};
|
|
833
|
+
var SUPPORTED_PROJECT_LANGUAGES = /* @__PURE__ */ new Set([
|
|
834
|
+
"EN",
|
|
835
|
+
"CN_S",
|
|
836
|
+
"CN_T",
|
|
837
|
+
"DE",
|
|
838
|
+
"FR",
|
|
839
|
+
"ES",
|
|
840
|
+
"JA",
|
|
841
|
+
"KO",
|
|
842
|
+
"PT",
|
|
843
|
+
"IT",
|
|
844
|
+
"HI",
|
|
845
|
+
"BN",
|
|
846
|
+
"UR",
|
|
847
|
+
"AR",
|
|
848
|
+
"TR",
|
|
849
|
+
"RU",
|
|
850
|
+
"MS",
|
|
851
|
+
"IN",
|
|
852
|
+
"ID"
|
|
853
|
+
]);
|
|
854
|
+
function resolveLanguageTag(tag) {
|
|
855
|
+
if (!tag || typeof tag !== "string") return void 0;
|
|
856
|
+
const normalized = tag.trim();
|
|
857
|
+
if (!normalized) return void 0;
|
|
858
|
+
const projectCode = normalized.toUpperCase().replace(/-/g, "_");
|
|
859
|
+
if (SUPPORTED_PROJECT_LANGUAGES.has(projectCode)) return projectCode;
|
|
860
|
+
const lower = normalized.toLowerCase();
|
|
861
|
+
if (LANGUAGE_MAP[lower]) return LANGUAGE_MAP[lower];
|
|
862
|
+
const primary = lower.split(/[-_]/)[0];
|
|
863
|
+
return LANGUAGE_MAP[primary];
|
|
864
|
+
}
|
|
865
|
+
function getLanguage() {
|
|
866
|
+
const candidates = detectCandidates();
|
|
867
|
+
for (const tag of candidates) {
|
|
868
|
+
const code = resolveLanguageTag(tag);
|
|
869
|
+
if (code) return code;
|
|
870
|
+
}
|
|
871
|
+
return "EN";
|
|
872
|
+
}
|
|
873
|
+
|
|
684
874
|
// src/theme-config.ts
|
|
685
875
|
function extractDefaultsFromSchema(schema) {
|
|
686
876
|
if (!schema || typeof schema !== "object") return void 0;
|
|
@@ -699,6 +889,31 @@
|
|
|
699
889
|
}
|
|
700
890
|
return void 0;
|
|
701
891
|
}
|
|
892
|
+
function lookupI18nRuntime(runtime, key, langCode) {
|
|
893
|
+
var _a, _b;
|
|
894
|
+
const map = runtime[key];
|
|
895
|
+
if (!map || typeof map !== "object") return void 0;
|
|
896
|
+
return (_b = (_a = map[langCode]) != null ? _a : map["en"]) != null ? _b : Object.values(map)[0];
|
|
897
|
+
}
|
|
898
|
+
function resolveI18nRefs(config, i18nRecord, langCode) {
|
|
899
|
+
var _a;
|
|
900
|
+
if (!config || typeof config !== "object" || Array.isArray(config)) return;
|
|
901
|
+
const runtime = (_a = i18nRecord.runtime) != null ? _a : {};
|
|
902
|
+
for (const key of Object.keys(config)) {
|
|
903
|
+
const value = config[key];
|
|
904
|
+
if (typeof value === "string") {
|
|
905
|
+
if (value.startsWith("i18n.runtime.")) {
|
|
906
|
+
const i18nKey = value.slice("i18n.runtime.".length);
|
|
907
|
+
const resolved = lookupI18nRuntime(runtime, i18nKey, langCode);
|
|
908
|
+
if (resolved !== void 0) {
|
|
909
|
+
config[key] = resolved;
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
} else if (value !== null && typeof value === "object" && !Array.isArray(value)) {
|
|
913
|
+
resolveI18nRefs(value, i18nRecord, langCode);
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
}
|
|
702
917
|
function resolveImagePaths(config, assetRecordByPath) {
|
|
703
918
|
if (!assetRecordByPath || !config || typeof config !== "object") return;
|
|
704
919
|
for (const key of Object.keys(config)) {
|
|
@@ -726,7 +941,7 @@
|
|
|
726
941
|
return target;
|
|
727
942
|
}
|
|
728
943
|
function setConfig(configList, config) {
|
|
729
|
-
const { assetRecordByPath } = config;
|
|
944
|
+
const { assetRecordByPath, i18nRecord } = config;
|
|
730
945
|
const resolvedConfigs = configList.map((item) => {
|
|
731
946
|
var _a;
|
|
732
947
|
if (!item) return {};
|
|
@@ -737,6 +952,11 @@
|
|
|
737
952
|
for (const data of rest) {
|
|
738
953
|
deepMerge(mergedConfig, data);
|
|
739
954
|
}
|
|
955
|
+
if (i18nRecord) {
|
|
956
|
+
const langCode = getLanguageCode();
|
|
957
|
+
console.log("detect target langCode", langCode);
|
|
958
|
+
resolveI18nRefs(mergedConfig, i18nRecord, langCode);
|
|
959
|
+
}
|
|
740
960
|
resolveImagePaths(mergedConfig, assetRecordByPath);
|
|
741
961
|
_cachedConfig = mergedConfig;
|
|
742
962
|
}
|
|
@@ -1540,6 +1760,31 @@
|
|
|
1540
1760
|
static isGoogle() {
|
|
1541
1761
|
return _sdk.getCurChannel() === "google";
|
|
1542
1762
|
}
|
|
1763
|
+
/**
|
|
1764
|
+
* 获取当前用户语言的 i18n 简码。
|
|
1765
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag)。
|
|
1766
|
+
*
|
|
1767
|
+
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
1768
|
+
*
|
|
1769
|
+
* @example
|
|
1770
|
+
* const langCode = sdk.getLanguageCode(); // 'zh'
|
|
1771
|
+
*/
|
|
1772
|
+
static getLanguageCode() {
|
|
1773
|
+
return getLanguageCode();
|
|
1774
|
+
}
|
|
1775
|
+
/**
|
|
1776
|
+
* 获取当前用户语言的业务代号。
|
|
1777
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
1778
|
+
* 并映射到业务语言代号(区分简繁中文)。
|
|
1779
|
+
*
|
|
1780
|
+
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
1781
|
+
*
|
|
1782
|
+
* @example
|
|
1783
|
+
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
1784
|
+
*/
|
|
1785
|
+
static getLanguage() {
|
|
1786
|
+
return getLanguage();
|
|
1787
|
+
}
|
|
1543
1788
|
/**
|
|
1544
1789
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
1545
1790
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -1602,7 +1847,7 @@
|
|
|
1602
1847
|
}
|
|
1603
1848
|
};
|
|
1604
1849
|
/** Current version of the SDK */
|
|
1605
|
-
_sdk.version = "1.0.
|
|
1850
|
+
_sdk.version = "1.0.18-beta.2";
|
|
1606
1851
|
/** Current maximum width of the playable ad container in pixels */
|
|
1607
1852
|
_sdk.maxWidth = Math.floor(window.innerWidth);
|
|
1608
1853
|
/** Current maximum height of the playable ad container in pixels */
|
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n 数据结构(仅 runtime,SDK 只处理游戏内运行时多语言):
|
|
3
|
+
* runtime: { [key]: { [langCode]: "文案" } }
|
|
4
|
+
*
|
|
5
|
+
* xplatform(配置平台 UI 标题)由外部配置平台自行解析,不传入 SDK。
|
|
6
|
+
*/
|
|
7
|
+
type I18nRecord = {
|
|
8
|
+
runtime?: Record<string, Record<string, string>>;
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
type EventName = 'playcraftInit' | 'playcraftReady' | 'playcraftStart' | 'playcraftInteractive' | 'playcraftInteraction' | 'playcraftChallengeStart' | 'playcraftChallengeProgress' | 'playcraftChallengeSuccess' | 'playcraftChallengeFailed' | 'playcraftResize' | 'playcraftPause' | 'playcraftResume' | 'playcraftVolume' | 'playcraftRetry' | 'playcraftFinish' | 'playcraftInstall';
|
|
2
12
|
|
|
3
13
|
/**
|
|
@@ -252,6 +262,27 @@ declare class sdk {
|
|
|
252
262
|
* 判断是否是 Google
|
|
253
263
|
*/
|
|
254
264
|
static isGoogle(): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* 获取当前用户语言的 i18n 简码。
|
|
267
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag)。
|
|
268
|
+
*
|
|
269
|
+
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* const langCode = sdk.getLanguageCode(); // 'zh'
|
|
273
|
+
*/
|
|
274
|
+
static getLanguageCode(): string;
|
|
275
|
+
/**
|
|
276
|
+
* 获取当前用户语言的业务代号。
|
|
277
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
278
|
+
* 并映射到业务语言代号(区分简繁中文)。
|
|
279
|
+
*
|
|
280
|
+
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
284
|
+
*/
|
|
285
|
+
static getLanguage(): string;
|
|
255
286
|
/**
|
|
256
287
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
257
288
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -269,7 +300,10 @@ declare class sdk {
|
|
|
269
300
|
* { assetRecordByPath: imageAssets }
|
|
270
301
|
* );
|
|
271
302
|
*/
|
|
272
|
-
static setConfig(configList: any[], config:
|
|
303
|
+
static setConfig(configList: any[], config: {
|
|
304
|
+
assetRecordByPath: Record<string, string>;
|
|
305
|
+
i18nRecord?: I18nRecord;
|
|
306
|
+
}): void;
|
|
273
307
|
/**
|
|
274
308
|
* 获取合并后的主题配置。
|
|
275
309
|
* 返回 schema 默认值与用户主题数据深度合并后的结果。
|
|
@@ -323,4 +357,31 @@ declare function hideWechatGuide(): void;
|
|
|
323
357
|
*/
|
|
324
358
|
declare function removeWechatGuide(): void;
|
|
325
359
|
|
|
326
|
-
|
|
360
|
+
/**
|
|
361
|
+
* 语言检测模块(零外部依赖)。
|
|
362
|
+
*
|
|
363
|
+
* 提供两个层级的语言获取:
|
|
364
|
+
* - getLanguageCode() → i18n 简码(en / zh / ja / ko …),用于 i18n.runtime 查表
|
|
365
|
+
* - getLanguage() → 业务语言代号(EN / CN_S / CN_T / DE …),用于游戏内资源选择
|
|
366
|
+
*
|
|
367
|
+
* 探测优先级(与 i18next-browser-languagedetector 保持一致):
|
|
368
|
+
* 1. URL querystring (?lng=xx)
|
|
369
|
+
* 2. localStorage (i18nextLng)
|
|
370
|
+
* 3. cookie (i18next)
|
|
371
|
+
* 4. navigator.languages / navigator.language
|
|
372
|
+
* 5. <html lang="xx">
|
|
373
|
+
*/
|
|
374
|
+
/**
|
|
375
|
+
* 多源探测当前用户语言,并归一化为 i18n 简码。
|
|
376
|
+
*
|
|
377
|
+
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
378
|
+
*/
|
|
379
|
+
declare function getLanguageCode(): string;
|
|
380
|
+
/**
|
|
381
|
+
* 多源探测当前用户语言,返回业务语言代号。
|
|
382
|
+
*
|
|
383
|
+
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
384
|
+
*/
|
|
385
|
+
declare function getLanguage(): string;
|
|
386
|
+
|
|
387
|
+
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor, getLanguage, getLanguageCode, hideWechatGuide, removeWechatGuide, sdk, showWechatGuide };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* i18n 数据结构(仅 runtime,SDK 只处理游戏内运行时多语言):
|
|
3
|
+
* runtime: { [key]: { [langCode]: "文案" } }
|
|
4
|
+
*
|
|
5
|
+
* xplatform(配置平台 UI 标题)由外部配置平台自行解析,不传入 SDK。
|
|
6
|
+
*/
|
|
7
|
+
type I18nRecord = {
|
|
8
|
+
runtime?: Record<string, Record<string, string>>;
|
|
9
|
+
};
|
|
10
|
+
|
|
1
11
|
type EventName = 'playcraftInit' | 'playcraftReady' | 'playcraftStart' | 'playcraftInteractive' | 'playcraftInteraction' | 'playcraftChallengeStart' | 'playcraftChallengeProgress' | 'playcraftChallengeSuccess' | 'playcraftChallengeFailed' | 'playcraftResize' | 'playcraftPause' | 'playcraftResume' | 'playcraftVolume' | 'playcraftRetry' | 'playcraftFinish' | 'playcraftInstall';
|
|
2
12
|
|
|
3
13
|
/**
|
|
@@ -252,6 +262,27 @@ declare class sdk {
|
|
|
252
262
|
* 判断是否是 Google
|
|
253
263
|
*/
|
|
254
264
|
static isGoogle(): boolean;
|
|
265
|
+
/**
|
|
266
|
+
* 获取当前用户语言的 i18n 简码。
|
|
267
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag)。
|
|
268
|
+
*
|
|
269
|
+
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* const langCode = sdk.getLanguageCode(); // 'zh'
|
|
273
|
+
*/
|
|
274
|
+
static getLanguageCode(): string;
|
|
275
|
+
/**
|
|
276
|
+
* 获取当前用户语言的业务代号。
|
|
277
|
+
* 多源探测(querystring → localStorage → cookie → navigator → html tag),
|
|
278
|
+
* 并映射到业务语言代号(区分简繁中文)。
|
|
279
|
+
*
|
|
280
|
+
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
281
|
+
*
|
|
282
|
+
* @example
|
|
283
|
+
* const lang = sdk.getLanguage(); // 'CN_S'
|
|
284
|
+
*/
|
|
285
|
+
static getLanguage(): string;
|
|
255
286
|
/**
|
|
256
287
|
* 设置主题配置,支持传入多份 JSON5 配置。
|
|
257
288
|
* 每一份配置都可以是 JSON Schema(带 $schema 字段),会自动提取其中的 default 值。
|
|
@@ -269,7 +300,10 @@ declare class sdk {
|
|
|
269
300
|
* { assetRecordByPath: imageAssets }
|
|
270
301
|
* );
|
|
271
302
|
*/
|
|
272
|
-
static setConfig(configList: any[], config:
|
|
303
|
+
static setConfig(configList: any[], config: {
|
|
304
|
+
assetRecordByPath: Record<string, string>;
|
|
305
|
+
i18nRecord?: I18nRecord;
|
|
306
|
+
}): void;
|
|
273
307
|
/**
|
|
274
308
|
* 获取合并后的主题配置。
|
|
275
309
|
* 返回 schema 默认值与用户主题数据深度合并后的结果。
|
|
@@ -323,4 +357,31 @@ declare function hideWechatGuide(): void;
|
|
|
323
357
|
*/
|
|
324
358
|
declare function removeWechatGuide(): void;
|
|
325
359
|
|
|
326
|
-
|
|
360
|
+
/**
|
|
361
|
+
* 语言检测模块(零外部依赖)。
|
|
362
|
+
*
|
|
363
|
+
* 提供两个层级的语言获取:
|
|
364
|
+
* - getLanguageCode() → i18n 简码(en / zh / ja / ko …),用于 i18n.runtime 查表
|
|
365
|
+
* - getLanguage() → 业务语言代号(EN / CN_S / CN_T / DE …),用于游戏内资源选择
|
|
366
|
+
*
|
|
367
|
+
* 探测优先级(与 i18next-browser-languagedetector 保持一致):
|
|
368
|
+
* 1. URL querystring (?lng=xx)
|
|
369
|
+
* 2. localStorage (i18nextLng)
|
|
370
|
+
* 3. cookie (i18next)
|
|
371
|
+
* 4. navigator.languages / navigator.language
|
|
372
|
+
* 5. <html lang="xx">
|
|
373
|
+
*/
|
|
374
|
+
/**
|
|
375
|
+
* 多源探测当前用户语言,并归一化为 i18n 简码。
|
|
376
|
+
*
|
|
377
|
+
* @returns i18n 简码:en | zh | ja | ko | de | fr | es | pt | it | hi | bn | ur | ar | tr | ru | ms | id,默认 'en'
|
|
378
|
+
*/
|
|
379
|
+
declare function getLanguageCode(): string;
|
|
380
|
+
/**
|
|
381
|
+
* 多源探测当前用户语言,返回业务语言代号。
|
|
382
|
+
*
|
|
383
|
+
* @returns 业务代号:EN | CN_S | CN_T | DE | FR | ES | JA | KO | PT | IT | HI | BN | UR | AR | TR | RU | MS | IN | ID,默认 'EN'
|
|
384
|
+
*/
|
|
385
|
+
declare function getLanguage(): string;
|
|
386
|
+
|
|
387
|
+
export { type CursorOptions, type I18nRecord, sdk as default, disableCustomCursor, enableCustomCursor, getLanguage, getLanguageCode, hideWechatGuide, removeWechatGuide, sdk, showWechatGuide };
|