(core) updates from grist-core

This commit is contained in:
Paul Fitzpatrick
2023-02-06 08:51:26 -05:00
18 changed files with 914 additions and 45 deletions

View File

@@ -141,7 +141,7 @@ function BaseView(gristDoc, viewSectionModel, options) {
}).extend({deferred: true}));
// Update the cursor whenever linkedRowId() changes.
this.autoDispose(this.linkedRowId.subscribe(rowId => this.setCursorPos({rowId})));
this.autoDispose(this.linkedRowId.subscribe(rowId => this.setCursorPos({rowId: rowId || 'new'})));
// Indicated whether editing the section should be disabled given the current linking state.
this.disableEditing = this.autoDispose(ko.computed(() => {

View File

@@ -40,7 +40,13 @@ export async function setupLocale() {
const resourceUrl = loadPath.replace('{{lng}}', lang.replace("-", "_")).replace('{{ns}}', n);
const response = await fetch(resourceUrl);
if (!response.ok) {
throw new Error(`Failed to load ${resourceUrl}`);
// Throw only if we don't have any fallbacks.
if (lang === i18next.options.fallbackLng && n === i18next.options.defaultNS) {
throw new Error(`Failed to load ${resourceUrl}`);
} else {
console.warn(`Failed to load ${resourceUrl}`);
return;
}
}
i18next.addResourceBundle(lang, n, await response.json());
}

View File

@@ -137,20 +137,18 @@ export class AccountPage extends Disposable {
),
dom.create(MFAConfig, user),
),
css.header(t("Theme")),
// Custom CSS is incompatible with custom themes.
enableCustomCss ? null : [
css.header(t("Theme")),
dom.create(ThemeConfig, this._appModel),
css.subHeader(t("Language")),
css.dataRow({ style: 'width: 300px'},
select(userLocale, languageOptions, {
renderOptionArgs: () => {
return dom.cls(cssFirstUpper.className);
}
}),
testId('language'),
)
],
enableCustomCss ? null : dom.create(ThemeConfig, this._appModel),
css.subHeader(t("Language")),
css.dataRow({ style: 'width: 300px'},
select(userLocale, languageOptions, {
renderOptionArgs: () => {
return dom.cls(cssFirstUpper.className);
}
}),
testId('language'),
),
css.header(t("API")),
css.dataRow(css.inlineSubHeader(t("API Key")), css.content(
dom.create(ApiKey, {

View File

@@ -75,7 +75,12 @@ export function getCountryCode(locale: string) {
if (locale === 'en') { return 'US'; }
let countryCode = locale.split(/[-_]/)[1];
if (countryCode) { return countryCode.toUpperCase(); }
countryCode = locale.toUpperCase();
// Some defaults that we support and can't be read from language code.
countryCode = {
'uk': 'UA', // Ukraine
}[locale] ?? locale.toUpperCase();
// Test if we can use language as a country code.
if (localeCodes.map(code => code.split(/[-_]/)[1]).includes(countryCode)) {
return countryCode;