Files
Irvan Fauziansyah e2d03f9b25 feat: add i18n framework with Indonesian translation support (#124)
* feat: add i18n support with separate translation files

- Extract translations from store.js to separate files for easier management
- Add translation files for English (en.js), Indonesian (id.js), Turkish (tr.js), and Chinese (zh.js)
- Load translations via window.translations object before Alpine store initialization
- Add Bahasa Indonesia option to language selector

* feat: translate remaining hardcoded UI strings

- Update index.html to use t() for Menu and GitHub labels
- Update views to translate Tier, Quota, Live, tier badges, and close button
- Update components to use translated error messages and confirmation dialogs
- Update utils to use translated validation and error messages
- Update app-init.js to use translated OAuth success/error messages
2026-01-15 23:33:38 +08:00

43 lines
1.5 KiB
JavaScript

/**
* Model Configuration Utilities
* Shared functions for model configuration updates
*/
window.ModelConfigUtils = window.ModelConfigUtils || {};
/**
* Update model configuration with authentication and optimistic updates
* @param {string} modelId - The model ID to update
* @param {object} configUpdates - Configuration updates (pinned, hidden, alias, mapping)
* @returns {Promise<void>}
*/
window.ModelConfigUtils.updateModelConfig = async function(modelId, configUpdates) {
return window.ErrorHandler.safeAsync(async () => {
const store = Alpine.store('global');
const { response, newPassword } = await window.utils.request('/api/models/config', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ modelId, config: configUpdates })
}, store.webuiPassword);
// Update password if server provided a new one
if (newPassword) {
store.webuiPassword = newPassword;
}
if (!response.ok) {
throw new Error(store.t('failedToUpdateModelConfig'));
}
// Optimistic update of local state
const dataStore = Alpine.store('data');
dataStore.modelConfig[modelId] = {
...dataStore.modelConfig[modelId],
...configUpdates
};
// Recompute quota rows to reflect changes
dataStore.computeQuotaRows();
}, Alpine.store('global').t('failedToUpdateModelConfig'));
};