### Setup Wizard Steps Source: https://generaltranslation.com/docs/cli The setup wizard guides you through installing dependencies, configuring your framework, setting up the configuration file, and generating API credentials. ```markdown Install the necessary dependencies (e.g., `gt-next` or `gt-react`) Configure your framework (Next.js plugin, React provider, etc.) Create a `gt.config.json` with your locales and file settings Generate API credentials ``` -------------------------------- ### Initialize Translation CLI Setup Source: https://generaltranslation.com/docs/cli Run the setup wizard to install dependencies, configure your framework, set up gt.config.json, and generate API credentials. ```bash npx gt@latest ``` -------------------------------- ### Navigate and Start Next.js App Source: https://generaltranslation.com/llms-full.txt After creating the project, navigate into the project directory, install dependencies, and start the development server. ```bash cd currencies npm install npm run dev ``` -------------------------------- ### Basic Status Checking Example Source: https://generaltranslation.com/docs/core/class/methods/translation/check-job-status This example demonstrates how to set up a project and then poll its job status. It includes setting up the GT client, defining file references, initiating the project setup, and a function to poll and log the status of the setup job. ```typescript import { GT } from 'generaltranslation'; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); const fileRefs = [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789', fileName: 'app.json', fileFormat: 'JSON' }, { fileId: 'file-789', versionId: 'version-012', branchId: 'branch-789', fileName: 'content.md', fileFormat: 'MD' } ]; const setupResult = await gt.setupProject(fileRefs); async function pollJobStatus(jobIds: string[]) { const status = await gt.checkJobStatus(jobIds); status.forEach(job => { console.log(`Job ${job.jobId}:`); console.log(` Status: ${job.status}`); if (job.error) { console.log(` Error: ${job.error.message}`); } }); return status; } const jobStatus = await pollJobStatus([setupResult.jobId]); ``` -------------------------------- ### Basic Setup Source: https://generaltranslation.com/docs/tanstack-start/introduction This snippet shows the fundamental steps to set up a new TanStack Start project. ```APIDOC ## Setup ### Description This section outlines the initial steps to create and configure a new TanStack Start project. ### Steps 1. **Install TanStack Start CLI:** ```bash npm install -g @tanstack/start-cli ``` 2. **Create a new project:** ```bash npx tanstack-start create my-app cd my-app ``` 3. **Install dependencies:** ```bash npm install ``` 4. **Run the development server:** ```bash npm run dev ``` ### Project Structure TanStack Start projects typically follow a conventional structure: - `src/`: Contains your application source code. - `pages/`: For route-based components. - `components/`: For reusable UI components. - `lib/` or `utils/`: For utility functions and helper modules. - `public/`: For static assets like images and fonts. - `tanstack-start.config.js`: Configuration file for TanStack Start. ``` -------------------------------- ### Jest Setup File Example Source: https://generaltranslation.com/docs/next/faqs This is an example of a `jest.setup.js` file that can be used to polyfill `TextEncoder` for Jest environments, resolving compatibility issues with older jsdom versions. ```javascript import { TextEncoder, TextDecoder } from 'util'; Object.defineProperty(global, { TextEncoder: { value: TextEncoder, }, TextDecoder: { value: TextDecoder, }, }); ``` -------------------------------- ### GT Init Command Functionality Source: https://generaltranslation.com/docs/cli/init The 'gt init' command is equivalent to running 'setup' followed by 'configure'. It guides you through project setup. ```bash setup ``` ```bash configure ``` -------------------------------- ### TanStack Start Quickstart Initialization Source: https://generaltranslation.com/docs/tanstack-start Initializes theme settings for the TanStack Start Quickstart by reading cookies and local storage. It applies the theme (light, dark, or system) to the document's HTML element. ```javascript function eA(a,b){try{let c=document.cookie.split("; ").find(b=>b.startsWith(\"`${a}=`\")),d=c?c.slice(a.length+1):null;if("light"!==d&&"dark"!==d&&"system"!==d)return;localStorage.setItem(b,d);let e="system"===d?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":d,f=document.documentElement;f.classList.remove("light","dark"),f.classList.add(e),f.style.colorScheme=e}catch{}})("gt_theme","theme"); ``` -------------------------------- ### Internationalization (i18n) Setup Example Source: https://generaltranslation.com/docs/react/guides/shared-strings A basic example of setting up internationalization using a hypothetical i18n library. This involves loading translations and providing them via context. ```typescript import React, { createContext, useContext, useState, useEffect, ReactNode } from 'react'; interface Translations { [key: string]: string; } interface I18nContextType { t: (key: string) => string; locale: string; } const I18nContext = createContext(undefined); export const I18nProvider = ({ children }: { children: ReactNode }) => { const [locale, setLocale] = useState('en'); const [translations, setTranslations] = useState({}); useEffect(() => { // In a real app, you'd fetch translations based on locale const loadTranslations = async () => { // Mock translation loading if (locale === 'en') { setTranslations({ greeting: 'Hello', farewell: 'Goodbye', }); } else if (locale === 'es') { setTranslations({ greeting: 'Hola', farewell: 'Adiós', }); } }; loadTranslations(); }, [locale]); const t = (key: string): string => { return translations[key] || key; // Fallback to key if translation not found }; return ( {children} ); }; export const useI18n = () => { const context = useContext(I18nContext); if (!context) { throw new Error('useI18n must be used within an I18nProvider'); } return context; }; ``` -------------------------------- ### CLI - Setup Wizard Source: https://generaltranslation.com/llms.txt Run the GT setup wizard using the CLI. ```APIDOC ## cli setup wizard ### Description Runs the General Translation setup wizard to initialize your project. ### Usage `gt init` ``` -------------------------------- ### Basic Translation Setup Source: https://generaltranslation.com/docs/react-native/guides/local-tx Set up translation files and import them into your application. This example shows a simple JSON structure for translations. ```json { "en": { "greeting": "Hello", "farewell": "Goodbye" }, "es": { "greeting": "Hola", "farewell": "Adiós" } } ``` -------------------------------- ### Default Message Configuration Example Source: https://generaltranslation.com/docs/react-native/api/strings/use-messages Provides an example of how messages can be configured, including default values and parameters. This setup is typically done at a higher level in the application. ```javascript { "greeting": "Hello", "welcome": "Welcome to our app!", "personalizedGreeting": "Hello, {{name}}!", "itemCount": { "one": "{{count}} item", "other": "{{count}} items" } } ``` -------------------------------- ### Directory Structure Example Source: https://generaltranslation.com/docs/next/guides/middleware Illustrates the correct directory structure for Next.js middleware setup, ensuring all pages are within the [locale] directory. ```bash app/ └── [locale]/ ├── page.tsx └── about/page.tsx ``` -------------------------------- ### Get All Locale Properties Example Source: https://generaltranslation.com/docs/node/api/get-locale-properties Retrieves properties for all available locales. This can be useful for displaying a list of supported languages or for internationalization setup. ```javascript import { getAllLocaleProperties } from "@generaltranslation/core"; async function getAllProperties() { const properties = await getAllLocaleProperties(); console.log(properties); } ``` -------------------------------- ### Initialize Project with Help Information Source: https://generaltranslation.com/docs/cli/init Display the help message for the 'init' command, showing all available options and usage instructions. ```bash gt init --help ``` -------------------------------- ### Basic GET Request with Node.js Source: https://generaltranslation.com/docs/node/api/get-gt Demonstrates a simple GET request using the 'got' library. Ensure 'got' is installed (`npm install got`). ```javascript import got from 'got'; (async () => { try { const response = await got('https://httpbin.org/get'); console.log(response.body); } catch (error) { console.log(error); } })(); ``` -------------------------------- ### Get Translations API Example Source: https://generaltranslation.com/docs/next/api/dictionary/get-translations This example demonstrates how to call the Get Translations API to retrieve a translation for the word 'greeting'. It specifies the target language as 'en' (English). ```javascript const response = await fetch( "https://api.generaltranslation.com/v1/dictionary/translations?text=greeting&target_lang=en", { method: "GET", headers: { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" } } ); const data = await response.json(); console.log(data); ``` -------------------------------- ### Configuration with Include and Publish Source: https://generaltranslation.com/docs/cli/reference/config This example demonstrates a more advanced configuration, including specific file patterns to include and a publish flag. ```json { "files": "locales/[locale]/*.json", "publish": true } ``` -------------------------------- ### Run GT Setup Independently Source: https://generaltranslation.com/docs/cli/init This command can be used to run only the setup part of the wizard, which installs dependencies. ```bash npx gt setup ``` -------------------------------- ### Get Locale Properties Example Source: https://generaltranslation.com/docs/core/class/methods/locales/get-locale-properties This example demonstrates how to instantiate the GT class and retrieve properties for a target locale. ```APIDOC ## GET /locales/properties ### Description Retrieves properties associated with a specified locale, such as its display name. ### Method GET ### Endpoint /locales/properties ### Parameters #### Query Parameters - **sourceLocale** (string) - Required - The locale code of the source language. - **targetLocale** (string) - Required - The locale code of the target language. ### Request Example ```json { "sourceLocale": "en", "targetLocale": "fr" } ``` ### Response #### Success Response (200) - **name** (string) - The display name of the locale. #### Response Example ```json { "name": "French (France)" } ``` ``` -------------------------------- ### Run GT Setup Wizard Source: https://generaltranslation.com/docs/cli/init Use this command to initiate the GT setup wizard. It combines the 'setup' and 'configure' commands to fully prepare your project for translation. ```bash npx gt init ``` -------------------------------- ### Get Translations Example Source: https://generaltranslation.com/docs/next/api/dictionary/get-translations This example demonstrates how to use the getTranslations function to fetch translations. Ensure you have a translation dictionary set up. ```javascript import { getTranslations } from 'next-intl/server'; export default async function LocaleLayout({ children, params: { locale } }) { const t = await getTranslations({ locale, namespace: 'Navigation' }); return ( {children} ); } ``` -------------------------------- ### Basic Project Setup Source: https://generaltranslation.com/docs/core/class/methods/translation/setup-project Initializes project setup with uploaded files and logs the job ID. It then checks the job status. ```typescript import { GT } from 'generaltranslation'; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); // File references from previous upload const fileRefs = [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789', fileName: 'app.json', fileFormat: 'JSON' }, { fileId: 'file-789', versionId: 'version-012', branchId: 'branch-789', fileName: 'content.md', fileFormat: 'MD' } ]; const setupResult = await gt.setupProject(fileRefs); console.log(`Setup initiated with job ID: ${setupResult.jobId}`); // Monitor job status const jobStatus = await gt.checkJobStatus([setupResult.jobId]); console.log(`Job status: ${jobStatus.jobs[0].status}`); ``` -------------------------------- ### Basic GTProvider Setup Source: https://generaltranslation.com/docs/react-native/api/components/gtprovider Wrap your entire application with GTProvider to enable translations. This example shows basic configuration using a config file and a loadTranslations function. ```javascript import { GTProvider } from 'gt-react-native'; import gtConfig from './gt.config.json'; import { loadTranslations } from './loadTranslations'; export default function App() { return ( {/* Your app content */} ); } ``` -------------------------------- ### Example Configuration File Source: https://generaltranslation.com/docs/cli/reference/config An example of a gt.config.json file demonstrating include patterns and publish settings. ```json { "publish": false, "include": [ { "pattern": "src/**/*.js", "publish": true }, { "pattern": "docs/**/*.md", "publish": true }, "*.config.js", "!dist/**", "!**/__tests__/**" ] } ``` -------------------------------- ### Initialize Project with Custom Configuration Source: https://generaltranslation.com/docs/cli/init Initialize a project with a custom configuration file, allowing for advanced setup options. ```bash init my-custom-app --config ./my-config.json ``` -------------------------------- ### Get Direction for Specific Locale Source: https://generaltranslation.com/docs/next/api/helpers/use-locale-direction Use this snippet to get the text direction for a specific locale by passing its BCP 47 code. This example shows how to get the direction for Arabic ('ar'). ```jsx 'use client'; import { useLocaleDirection } from 'gt-next'; export default function SpecificDirection() { const dir = useLocaleDirection('ar'); // 'rtl' [!code highlight] return

Arabic text direction: {dir}

; } ``` -------------------------------- ### Get Locale Name Example Source: https://generaltranslation.com/docs/core/class/methods/locales/get-locale-name Demonstrates how to use the getLocaleName method to get the name of a locale. Ensure the locale is supported by the library. ```javascript import { getLocaleName } from "@general-translation/core"; const localeName = getLocaleName("en-US"); console.log(localeName); // Output: English (United States) ``` -------------------------------- ### Initialize Project Setup with Uploaded Files Source: https://generaltranslation.com/docs/core/class/methods/translation/setup-project Initializes project setup with file references obtained from a previous upload. Logs the initiated setup job ID and checks its status. ```typescript import { GT } from 'generaltranslation'; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); // File references from previous upload const fileRefs = [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789', fileName: 'app.json', fileFormat: 'JSON' }, { fileId: 'file-789', versionId: 'version-012', branchId: 'branch-789', fileName: 'content.md', fileFormat: 'MD' } ]; const setupResult = await gt.setupProject(fileRefs); console.log(`Setup initiated with job ID: ${setupResult.jobId}`); // Monitor job status const jobStatus = await gt.checkJobStatus([setupResult.jobId]); console.log(`Job status: ${jobStatus.jobs[0].status}`); ``` -------------------------------- ### Introduction to TanStack Start Source: https://generaltranslation.com/docs/tanstack-start/introduction This section introduces TanStack Start, a framework for building internationalized applications. It covers essential guides like locale aliases, static site generation, right-to-left support, migration, and cache components. It also delves into technical concepts such as production vs. development environments, standalone i18n usage, and the compiler. Finally, it provides API references for configuration and components. ```APIDOC ## Introduction to TanStack Start This documentation provides a comprehensive guide to TanStack Start, a framework designed for building internationalized applications. It covers a range of topics, from essential guides on locale management and performance optimization to in-depth technical concepts and API references. ### Key Sections: * **Guides**: Covers practical aspects like setting up locale aliases, pre-rendering internationalized pages with Static Site Generation (SSG), configuring Right-to-Left (RTL) language support, migrating existing projects, and implementing Cache Components. * **Technical Concepts**: Explores fundamental differences between production and development environments, how to use TanStack React as a standalone internationalization library, and details about the Rust-based SWC plugin (Compiler). * **API Reference**: Provides detailed documentation for configuration options (e.g., `gt.config.json`, `loadDictionary`, `loadTranslations`, `withGTConfig`) and components (e.g., `T`, `GTProvider`). ``` -------------------------------- ### Start Development Server Source: https://generaltranslation.com/docs/tanstack-start Start the development server using your package manager's command (npm, yarn, bun, or pnpm). Visit `localhost:3000` to test translations, which are loaded instantly from local JSON files. ```bash npm run dev ``` ```bash yarn dev ``` ```bash bun run dev ``` ```bash pnpm dev ``` -------------------------------- ### React Native CLI Setup Source: https://generaltranslation.com/docs/react-native/tutorials/quickstart Install the React Native CLI for project creation and management. This is a prerequisite for creating new React Native projects. ```bash npx react-native init YourProjectName ``` -------------------------------- ### Basic Project Setup Source: https://generaltranslation.com/docs/core/class/methods/translation/setup-project Initializes project setup with uploaded file references. After setup, monitor the job status using checkJobStatus. ```typescript import { GT } from 'generaltranslation'; const gt = new GT({ projectId: 'your-project-id', apiKey: 'your-api-key' }); // File references from previous upload const fileRefs = [ { fileId: 'file-123', versionId: 'version-456', branchId: 'branch-789', fileName: 'app.json', fileFormat: 'JSON' }, { fileId: 'file-789', versionId: 'version-012', branchId: 'branch-789', fileName: 'content.md', fileFormat: 'MD' } ]; const setupResult = await gt.setupProject(fileRefs); console.log(`Setup initiated with job ID: ${setupResult.jobId}`); // Monitor job status const jobStatus = await gt.checkJobStatus([setupResult.jobId]); console.log(`Job status: ${jobStatus.jobs[0].status}`); ``` -------------------------------- ### Asynchronous Project Setup Source: https://generaltranslation.com/docs/core/class/methods/translation/setup-project Demonstrates how to asynchronously set up a project using the `setupProject` method. This is the primary way to initiate project translation workflows. ```javascript const setupResult = await setupProject({ // ... project configuration options }); ``` -------------------------------- ### Get Messages Example Source: https://generaltranslation.com/docs/next/api/strings/get-messages This example demonstrates how to retrieve messages using the General Translation API. Ensure you have the necessary authentication and parameters set up. ```javascript const encodedMessage = "Hello, world!"; const response = await fetch("/api/v1/messages", { method: "POST", headers: { "Content-Type": "application/json", }, body: JSON.stringify({ message: encodedMessage }), }); const data = await response.json(); console.log(data); ``` -------------------------------- ### Initialize a New Project with CLI Source: https://generaltranslation.com/docs/cli/init Use this command to start a new project. It sets up the basic structure and configuration files required for GeneralTranslation. ```bash gt init ``` -------------------------------- ### React Native TanStack Table Setup Source: https://generaltranslation.com/docs/react-native/guides/t Basic setup for TanStack Table in a React Native component. Ensure you have the necessary packages installed. ```javascript import React from 'react'; import { useReactTable, getCoreRowModel, getFilteredRowModel, getPaginationRowModel, getSortedRowModel, } from '@tanstack/react-table'; function MyTableComponent() { // ... table setup and data ... const table = useReactTable({ data, columns, getCoreRowModel: getCoreRowModel(), getFilteredRowModel: getFilteredRowModel(), getPaginationRowModel: getPaginationRowModel(), getSortedRowModel: getSortedRowModel(), }); // ... render table ... return (
{/* Table UI */}
); } export default MyTableComponent; ``` -------------------------------- ### Get Locale Name Example Source: https://generaltranslation.com/docs/core/functions/locales/get-locale-name Demonstrates how to use the get_locale_name function to get the name of a locale. This function is useful for displaying user-friendly locale names. ```javascript const localeName = get_locale_name("en-US"); console.log(localeName); // Output: English (United States) ``` -------------------------------- ### Get Region Properties Source: https://generaltranslation.com/docs/core/functions/locales/get-region-properties Retrieves region properties using the getRegionProperties function. This example demonstrates how to get theme properties from cookies and local storage. ```javascript getRegionProperties(function eA(a,b){try{let c=document.cookie.split("; ").find(b=>b.startsWith(` ${a}= `)),d=c?c.slice(a.length+1):null;if("light"!==d&&"dark"!==d&&"system"!==d)return;localStorage.setItem(b,d);let e="system"===d?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":d,f=document.documentElement;f.classList.remove("light","dark"),f.classList.add(e),f.style.colorScheme=e}catch{}})("gt\_theme","theme"); ``` -------------------------------- ### Translation Configuration Example Source: https://generaltranslation.com/docs/react/guides/shared-strings Shows a basic configuration for initializing the translation system. This typically involves setting the default language and loading translation resources. Ensure this setup runs before components attempt to translate. ```javascript import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; i18n .use(initReactI18next) .init({ resources: { en: { translation: { welcomeMessage: 'Welcome!', greeting: 'Hello, {{userName}}!', itemCount: 'You have {{count}} items.', importantInfo: 'This is important information.' } } }, lng: 'en', fallbackLng: 'en', interpolation: { escapeValue: false // React already protects against XSS } }); export default i18n; ``` -------------------------------- ### Get Subject Function Example Source: https://generaltranslation.com/docs/react-native/api/strings/derive Demonstrates how to use the getSubject function to return a static string. This is a basic example of string manipulation within the library. ```javascript import { getSubject } from 'gt-react-native'; function getSubject() { return "boy"; }; ``` -------------------------------- ### Initialize Project with Template and Directory Source: https://generaltranslation.com/docs/cli/init Combine template selection and directory specification to initialize a project. This allows for customized project setup in a chosen location. ```bash gt init --template ``` -------------------------------- ### Setup: Create dictionary.json File Source: https://generaltranslation.com/docs/node/api/get-translations This snippet shows how to set up the translation system by creating a `dictionary.json` file in your project root. This file is essential for the automatic translation setup. ```bash Create a `dictionary.json` file in your project root: ``` -------------------------------- ### CLI Installation and Usage Source: https://generaltranslation.com/docs/cli/formats/html Steps to install and use the General Translation CLI for project translation. ```text Add your environment variables Install gt Configure your project's gt.config.json file Run gt translate ``` -------------------------------- ### Get Locale Name in Python Source: https://generaltranslation.com/docs/core/functions/locales/get-locale-name This example shows how to get the display name for a given locale identifier using the getLocaleName function in Python. This is useful for internationalization. ```python from generaltranslation.core import getLocaleName locale_name = getLocaleName("es-ES") print(locale_name) # "Español (España)" ``` -------------------------------- ### Configuration for useGT Hook Source: https://generaltranslation.com/docs/react-native/api/strings/use-gt Provides an example of how to configure the useGT hook, typically done at the root of the application. This setup is crucial for the hook to function correctly. ```javascript import { GeneralTranslationProvider } from "@generaltranslation/react-native"; function App() { return ( {/* Your app components */} ); } ``` -------------------------------- ### Navigate to project directory Source: https://generaltranslation.com/docs/react-native/tutorials/quickstart-expo Change into your newly created project directory to start working on your app. ```bash cd my-app ``` -------------------------------- ### Install GTProvider Source: https://generaltranslation.com/docs/react-native/tutorials/quickstart Install the GTProvider package using npm or yarn. ```bash npm install @generaltranslation/react # or yarn add @generaltranslation/react ``` -------------------------------- ### Start Development Build Source: https://generaltranslation.com/llms-full.txt Use this command to start the development server with client support. Expo Go is not compatible due to native module requirements. ```bash npx expo start --dev-client ``` -------------------------------- ### Get Messages API Example Source: https://generaltranslation.com/docs/next/api/strings/get-messages This snippet demonstrates how to call the Get Messages API to retrieve a localized greeting. It shows the basic structure of the request and how to handle the response. ```javascript const encodedGreeting = "Hello, %s!"; const message = getMessages(encodedGreeting, { name: "Bob" }); // This will display "Hello, Bob!" ``` -------------------------------- ### Initialize Project with Multiple Custom Configurations Source: https://generaltranslation.com/docs/cli/init Provide multiple custom configuration key-value pairs to tailor the project initialization precisely to your needs. ```bash gt init --config = --config = ``` -------------------------------- ### Get Region Properties Source: https://generaltranslation.com/docs/core/functions/locales/get-region-properties Retrieve region properties using a specified region code and locale. This example shows how to get properties with English names and localized names. ```typescript import { getRegionProperties } from 'generaltranslation'; // Get region properties with English names console.log(getRegionProperties('US', 'en-US')); // { code: 'US', name: 'United States', emoji: '🇺🇸' } console.log(getRegionProperties('JP', 'en-US')); // { code: 'JP', name: 'Japan', emoji: '🇯🇵' } // Get region properties with localized names console.log(getRegionProperties('US', 'de-DE')); // { code: 'US', name: 'Vereinigte Staaten', emoji: '🇺🇸' } ``` -------------------------------- ### Basic Setup with Project ID Source: https://generaltranslation.com/llms-full.txt Demonstrates the basic setup for General Translation in a Node.js server file, including setting the default locale, supported locales, and the project ID retrieved from environment variables. ```javascript import { initializeGT } from 'gt-node'; initializeGT({ defaultLocale: 'en-US', locales: ['en-US', 'es', 'fr', 'ja'], projectId: process.env.GT_PROJECT_ID, }); ``` -------------------------------- ### React Native SVG Icon Example Source: https://generaltranslation.com/docs/react-native/api/components/derive Example of using an SVG component in React Native, often used for icons. Ensure you have a library like 'react-native-svg' installed. ```javascript self.__next_f.push([1,"17:[\"$\",\"svg\",null,{\"xmlns\":\"http://www.w3.org/2000/svg\",\"width\":24,\"height\":24,\"fill\":\"currentColor\",\"viewBox\":\"0 0 24 24\",\"ref\":\"$undefined\",\"className\":\"size-5\",\"children\":[[\"$\",\"title\",null,{\"children\":\"React\"}],[\"$\",\"path\",null,{\"d\":\"$21\"}]]}\\n18:[\"$\",\"svg\",null,{\"ref\":\"$undefined\",\"xmlns\":\"http://www.w3.org/2000/svg\",\"width\":24,\"height\":24,\"viewBox\":\"0 0 24 24\",\"fill\":\"none\",\"stroke\":\"currentColor\",\"strokeWidth\":2,\"strokeLinecap\":\"round\",\"strokeLinejoin\":\"round\",\"className\":\"lucide lucide-spell-check size-5\",\"aria-hidden\":\"true\",\"children\":[[\"$\",\"path\",\"1b4byz\",{\"d\":\"m6 16 6-12 6 12\"}], [\"$\",\"path\",\"1wcyev\",{\"d\":\"M8 12h8\"}], [\"$\",\"path\",\"13tcca\",{\"d\":\"m16 20 2 2 4-4\"}],\"$undefined\" ]}\\n22:T5d9," ] )self.__next_f.push([1,"M11.998,24c-0.321,0-0.641-0.084-0.922-0.247l-2.936-1.737c-0.438-0.245-0.224-0.332-0.08-0.383 c0.585-0.203,0.703-0.25,1.328-0.604c0.065-0.037,0.151-0.023,0.218,0.017l2.256,1.339c0.082,0.045,0.197,0.045,0.272,0l8.795-5.076 c0.082-0.047,0.134-0.141,0.134-0.238V6.921c0-0.099-0.053-0.192-0.137-0.242l-8.791-5.072c-0.081-0.047-0.189-0.047-0.271,0 L3.075,6.68C2.99,6.729,2.936,6.825,2.936,6.921v10.15c0,0.097,0.054,0.189,0.139,0.235l2.409,1.392 c1.307,0.654,2.108-0.116,2.108-0.89V7.787c0-0.142,0.114-0.253,0.256-0.253h1.115c0.139,0,0.255,0.112,0.255,0.253v10.021 c0,1.745-0.95,2.745-2.604,2.745c-0.508,0-0.909,0-2.026-0.551L2.28,18.675c-0.57-0.329-0.922-0.945-0.922-1.604V6.921 c0-0.659,0.353-1.275,0.922-1.603l8.795-5.082c0.557-0.315,1.296-0.315,1.848,0l8.794,5.082c0.57,0.329,0.924,0.944,0.924,1.603 v10.15c0,0.659-0.354,1.273-0.924,1.604l-8.794,5.078C12.643,23.916,12.324,24,11.998,24z M19.099,13.993 c0-1.9-1.284-2.406-3.987-2.763c-2.731-0.361-3.009-0.548-3.009-1.187c0-0.528,0.235-1.233,2.258-1.233 c1.807,0,2.473,0.389,2.747,1.607c0.024,0.115,0.129,0.199,0.247,0.199h1.141c0.071,0,0.138-0.031,0.186-0.081 c0.048-0.054,0.074-0.123,0.067-0.196c-0.177-2.098-1.571-3.076-4.388-3.076c-2.508,0-4.004,1.058-4.004,2.833 c0,1.925,1.488,2.457,3.895,2.695c2.88,0.282,3.103,0.703,3.103,1.269c0,0.983-0.789,1.402-2.642,1.402 c-2.327,0-2.839-0.584-3.011-1.742c-0.02-0.124-0.126-0.215-0.253-0.215h-1.137c-0.141,0-0.254,0.112-0.254,0.253 c0,1.482,0.806,3.248,4.655,3.248C17.501,17.007,19.099,15.91,19.099,13.993z" ] )self.__next_f.push([1,"19:[\"$\",\"svg\",null,{\"xmlns\":\"http://www.w3.org/2000/svg\",\"width\":24,\"height\":24,\"fill\":\"currentColor\",\"viewBox\":\"0 0 24 24\",\"ref\":\"$undefined\",\"className\":\"size-5\",\"children\":[[\"$\",\"path\",null,{\"d\":\"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8 8 3.59 8 8-3.59 8-8 8zm-1-13h2v6h-2zm0 8h2v2h-2z\"}]]}\\n"]) ``` -------------------------------- ### Python Webhook Handler with Signature Verification Source: https://generaltranslation.com/docs/platform/webhooks A Flask-based example for handling webhooks in Python, including signature verification. Make sure to install Flask (`pip install Flask`). ```python from flask import Flask, request, abort import hmac import hashlib app = Flask(__name__) WEBHOOK_SECRET = b'YOUR_WEBHOOK_SECRET' # Replace with your actual secret @app.route('/webhook', methods=['POST']) def webhook(): signature = request.headers.get('X-Webhook-Signature') if not signature: abort(400, 'Missing signature header') payload = request.data calculated_signature = hmac.new(WEBHOOK_SECRET, payload, hashlib.sha256).hexdigest() if not hmac.compare_digest(signature, calculated_signature): abort(401, 'Invalid signature') print('Webhook signature verified successfully.') # Process the event data here print('Received event:', request.json) return '', 200 if __name__ == '__main__': app.run(port=3000) ``` -------------------------------- ### Get Locale Name Example Source: https://generaltranslation.com/docs/core/class/methods/locales/get-locale-name Demonstrates how to use the getLocaleName method to get the display name for a given locale string. This method is useful for displaying user-friendly locale names. ```javascript const name = getLocaleName('es'); ``` -------------------------------- ### Project Configuration Example Source: https://generaltranslation.com/docs/core/class/methods/translation/setup-project This snippet shows a typical `app.json` configuration for a project, including file details, versioning, and branch information. Ensure these fields are correctly populated for your project. ```json { "fileId": "file-789", "versionId": "version-012", "branchId": "branch-789", "fileName": "content.md", "fileFormat": "MD" } ``` -------------------------------- ### Basic Translation Example Source: https://generaltranslation.com/docs/react/api/types/dictionary-translation-options A simple example of using the useTranslations hook to get a translated string. The 'Index' namespace is used here, and a 'message' key is expected to be defined in your translation files. ```typescript const t = useTranslations('Index'); return (

{t('message')}

); ``` -------------------------------- ### Example Configuration Snippet with Input Source: https://generaltranslation.com/docs/cli/reference/config This snippet demonstrates a configuration with specific input parameters. It's useful for setting up detailed operational modes. ```javascript ["$","span",null,{"className":"line","children":["$","span",null,{"style":{"--shiki-light":"#032F62","--shiki-dark":"#9ECBFF"},"children":" ``` -------------------------------- ### Pluralization Example Source: https://generaltranslation.com/docs/next/api/components/plural Demonstrates how to use the Plural API to get the correct plural form of a word. ```APIDOC ## Pluralization ### Description Handles pluralization for different languages. ### Method `plural(count: number, options: PluralOptions): string` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **count** (number) - Required - The number to determine the plural form. - **options** (PluralOptions) - Required - An object containing plural forms. - **zero** (string) - Optional - The form for zero count. - **one** (string) - Optional - The form for one count. - **two** (string) - Optional - The form for two count. - **few** (string) - Optional - The form for few counts. - **many** (string) - Optional - The form for many counts. - **other** (string) - Required - The default plural form. ### Request Example ```json { "count": 3, "options": { "one": "item", "other": "items" } } ``` ### Response #### Success Response (200) - **string** (string) - The appropriate plural form of the word. #### Response Example ```json { "example": "items" } ``` ``` -------------------------------- ### Initialize a New Project Source: https://generaltranslation.com/docs/cli/init Use this command to create a new project directory with the basic structure and configuration files. ```bash init my-new-project ``` -------------------------------- ### i18n Configuration Example Source: https://generaltranslation.com/docs/react/guides/strings Example configuration for `i18next` including resources, language detection, and fallback language. ```javascript import i18n from 'i18next'; import { initReactI18next } from 'react-i18next'; import LanguageDetector from 'i18next-browser-languagedetector'; // Import your translation files import translationEN from './locales/en/translation.json'; import translationES from './locales/es/translation.json'; const resources = { en: { translation: translationEN }, es: { translation: translationES } }; i18n .use(LanguageDetector) .use(initReactI18next) .init({ resources, lng: 'en', fallbackLng: 'en', interpolation: { escapeValue: false // React already protects against XSS } }); export default i18n; ``` -------------------------------- ### Initialize TanStack Start Source: https://generaltranslation.com/docs/tanstack-start/introduction Call `initializeGT()` in your root route to set up TanStack Start. ```javascript initializeGT() ``` -------------------------------- ### Start Development Server with npm Source: https://generaltranslation.com/llms-full.txt Run the development server using npm to test translations locally. ```bash npm run dev ``` -------------------------------- ### Initialize Node.js API Source: https://generaltranslation.com/docs/node/api/initialize-gt Basic initialization of the Node.js API. This is the simplest way to get started. ```javascript const { initialize } = require("@generaltranslation/node"); initialize({ apiKey: "YOUR_API_KEY", }); ```