* Refactor environment variables UI and update validation logic Enhanced the environment variables page layout for better responsiveness and structure by introducing new components and styles. Added `EnvListDisplay` for grouped variable display and adjusted several UI elements for clarity and consistency. Updated `NEXT_PUBLIC_SENTRY_ENVIRONMENT` validation to make it optional, aligning with updated requirements. * Add environment variable validation and enhance page headers Introduces robust validation for environment variables, ensuring correctness and contextual dependency checks. Updates page headers with titles and detailed descriptions for better usability and clarity. * Refactor variable page layout and improve code readability Rearranged className attributes in JSX for consistency and readability. Refactored map and enum validation logic for better formatting and maintainability. Applied minor corrections to types and formatting in other components. * Refactor styles and simplify component logic Updated badge variants to streamline styles and removed redundant hover states. Simplified logic in email page by extracting breadcrumb values and optimizing title rendering. Adjusted environment variables manager layout for cleaner rendering and removed unnecessary elements. * Add real-time translation updates with RxJS and UI improvements Introduced a Subject with debounce mechanism for handling translation updates, enhancing real-time editing in the translations comparison module. Improved UI components, including conditional rendering, better input handling, and layout adjustments. Implemented a server action for updating translations and streamlined type definitions in the emails page. * Enhance environment variable copying functionality and improve user feedback Updated the environment variables manager to copy structured environment variable data to the clipboard, improving usability. Adjusted toast notifications to provide clearer success and error messages during the copy process. Additionally, fixed a minor issue in the translations comparison component by ensuring proper filtering of keys based on the search input. * Add AI translation functionality and update dependencies Implemented a new action for translating missing strings using AI, enhancing the translations comparison component. Introduced a loading state during translation and improved error handling for translation updates. Updated package dependencies, including the addition of '@ai-sdk/openai' and 'ai' to facilitate AI-driven translations. Enhanced UI components for better user experience and streamlined translation management.
63 lines
1.5 KiB
TypeScript
63 lines
1.5 KiB
TypeScript
import { createI18nSettings } from '@kit/i18n';
|
|
|
|
/**
|
|
* The default language of the application.
|
|
* This is used as a fallback language when the selected language is not supported.
|
|
*
|
|
*/
|
|
const defaultLanguage = process.env.NEXT_PUBLIC_DEFAULT_LOCALE ?? 'en';
|
|
|
|
/**
|
|
* The list of supported languages.
|
|
* By default, only the default language is supported.
|
|
* Add more languages here if needed.
|
|
*/
|
|
export const languages: string[] = [defaultLanguage, 'it'];
|
|
|
|
/**
|
|
* The name of the cookie that stores the selected language.
|
|
*/
|
|
export const I18N_COOKIE_NAME = 'lang';
|
|
|
|
/**
|
|
* The default array of Internationalization (i18n) namespaces.
|
|
* These namespaces are commonly used in the application for translation purposes.
|
|
*
|
|
* Add your own namespaces here
|
|
**/
|
|
export const defaultI18nNamespaces = [
|
|
'common',
|
|
'auth',
|
|
'account',
|
|
'teams',
|
|
'billing',
|
|
'marketing',
|
|
];
|
|
|
|
/**
|
|
* Get the i18n settings for the given language and namespaces.
|
|
* If the language is not supported, it will fall back to the default language.
|
|
* @param language
|
|
* @param ns
|
|
*/
|
|
export function getI18nSettings(
|
|
language: string | undefined,
|
|
ns: string | string[] = defaultI18nNamespaces,
|
|
) {
|
|
let lng = language ?? defaultLanguage;
|
|
|
|
if (!languages.includes(lng)) {
|
|
console.warn(
|
|
`Language "${lng}" is not supported. Falling back to "${defaultLanguage}"`,
|
|
);
|
|
|
|
lng = defaultLanguage;
|
|
}
|
|
|
|
return createI18nSettings({
|
|
language: lng,
|
|
namespaces: ns,
|
|
languages,
|
|
});
|
|
}
|