/**
 * ANNOTATED COPY — every line explained
 * Source: src/i18n/index.ts
 * NOT used by the app — read this to learn how the real file works
 */
// Import from a relative file in the same project
import { Locale, TranslationDict } from './types';
// Import from a relative file in the same project
import { en } from './locales/en';
// Import from a relative file in the same project
import { sv } from './locales/sv';
// Import from a relative file in the same project
import { ur } from './locales/ur';
// (blank line — separates logical blocks for readability)
// Line 6: const dictionaries: Record<Locale, TranslationDict> = { e...
const dictionaries: Record<Locale, TranslationDict> = { en, sv, ur };
// (blank line — separates logical blocks for readability)
// Function declaration — reusable logic in this file
function resolve(obj: TranslationDict, path: string): string {
  // Line 9: const keys = path.split('.');
  const keys = path.split('.');
  // Line 10: let current: string | TranslationDict = obj;
  let current: string | TranslationDict = obj;
// (blank line — separates logical blocks for readability)
  // Line 12: for (const key of keys) {
  for (const key of keys) {
    // Conditional branch — different behavior based on runtime value
    if (typeof current !== 'object' || current === null || !(key in current)) {
      // Return value from function
      return path;
    // Closing brace — end of block (function, if, object, JSX)
    }
    // Line 16: current = current[key];
    current = current[key];
  // Closing brace — end of block (function, if, object, JSX)
  }
// (blank line — separates logical blocks for readability)
  // Return value from function
  return typeof current === 'string' ? current : path;
// Closing brace — end of block (function, if, object, JSX)
}
// (blank line — separates logical blocks for readability)
// Named export — utility function other files can import
export function createTranslator(locale: Locale) {
  // Line 23: const dict = dictionaries[locale] ?? dictionaries.en;
  const dict = dictionaries[locale] ?? dictionaries.en;
// (blank line — separates logical blocks for readability)
  // Return value from function
  return function t(path: string, params?: Record<string, string | number>): string {
    // Line 26: let text = resolve(dict, path);
    let text = resolve(dict, path);
// (blank line — separates logical blocks for readability)
    // Conditional branch — different behavior based on runtime value
    if (params) {
      // Line 29: Object.entries(params).forEach(([key, value]) => {
      Object.entries(params).forEach(([key, value]) => {
        // Line 30: text = text.replace(new RegExp(`\\{${key}\\}`, 'g'), Stri...
        text = text.replace(new RegExp(`\\{${key}\\}`, 'g'), String(value));
      // Closing brace — end of block (function, if, object, JSX)
      });
    // Closing brace — end of block (function, if, object, JSX)
    }
// (blank line — separates logical blocks for readability)
    // Return value from function
    return text;
  // Closing brace — end of block (function, if, object, JSX)
  };
// Closing brace — end of block (function, if, object, JSX)
}
// (blank line — separates logical blocks for readability)
// Named export — utility function other files can import
export function isRtl(locale: Locale): boolean {
  // Return value from function
  return locale === 'ur';
// Closing brace — end of block (function, if, object, JSX)
}
// (blank line — separates logical blocks for readability)
// Named export — utility function other files can import
export function getHtmlLang(locale: Locale): string {
  // Line 43: const map: Record<Locale, string> = { en: 'en', sv: 'sv',...
  const map: Record<Locale, string> = { en: 'en', sv: 'sv', ur: 'ur' };
  // Return value from function
  return map[locale];
// Closing brace — end of block (function, if, object, JSX)
}
