Files
NapCatQQ/.pnpm-store/v3/files/69/0568df2abdf259ea19f4def08b4182b279f9b735a678ad516912ae08e0ab53fda8414f5038b9cbcb7b27e9609e57f4ca328b9e7166ed2f9b26bd70bdd9fa0f
TanTan e311ca3275
Build NapCat Artifacts / Windows Loader Test (push) Canceled after 0s
Build NapCat Artifacts / Type Check & Test (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Framework (push) Canceled after 0s
Build NapCat Artifacts / Build NapCat.Shell (push) Canceled after 0s
docs: 仓库链接指向本镜像仓库
2026-11-13 09:25:58 +08:00

53 lines
2.5 KiB
Plaintext

/*
* Copyright 2020 Adobe. All rights reserved.
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. You may obtain a copy
* of the License at http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
* OF ANY KIND, either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/ class $d6fd23bc337660df$export$64839e615120df17 {
getStringForLocale(key, locale) {
let strings = this.messages[locale];
if (!strings) {
strings = $d6fd23bc337660df$var$getStringsForLocale(locale, this.messages, this.defaultLocale);
this.messages[locale] = strings;
}
let string = strings[key];
if (!string) throw new Error(`Could not find intl message ${key} in ${locale} locale`);
return string;
}
constructor(messages, defaultLocale = 'en-US'){
// Clone messages so we don't modify the original object.
// Filter out entries with falsy values which may have been caused by applying optimize-locales-plugin.
this.messages = Object.fromEntries(Object.entries(messages).filter(([, v])=>v));
this.defaultLocale = defaultLocale;
}
}
function $d6fd23bc337660df$var$getStringsForLocale(locale, strings, defaultLocale = 'en-US') {
// If there is an exact match, use it.
if (strings[locale]) return strings[locale];
// Attempt to find the closest match by language.
// For example, if the locale is fr-CA (French Canadian), but there is only
// an fr-FR (France) set of strings, use that.
// This could be replaced with Intl.LocaleMatcher once it is supported.
// https://github.com/tc39/proposal-intl-localematcher
let language = $d6fd23bc337660df$var$getLanguage(locale);
if (strings[language]) return strings[language];
for(let key in strings){
if (key.startsWith(language + '-')) return strings[key];
}
// Nothing close, use english.
return strings[defaultLocale];
}
function $d6fd23bc337660df$var$getLanguage(locale) {
if (Intl.Locale) return new Intl.Locale(locale).language;
return locale.split('-')[0];
}
export {$d6fd23bc337660df$export$64839e615120df17 as MessageDictionary};
//# sourceMappingURL=MessageDictionary.module.js.map