i18n Utilities
The i18n utilities provide translation management and language routing for the Chapinismos dictionary. The system supports Spanish (es) and English (en) locales.translations
Translation dictionary containing all UI strings for both Spanish and English.Translation object with Spanish (
es) and English (en) keysStructure
Available Translation Keys
Home Page Translations
Home Page Translations
home.title- Page titlehome.description- Meta descriptionhome.keywords- SEO keywordshome.subtitle- Hero subtitlehome.search.placeholder- Search input placeholderhome.featured- Featured words section titlehome.contribute.*- Contribution section stringshome.about.*- About section content
Search Page Translations
Search Page Translations
search.title- Search page titlesearch.subtitle- Search subtitlesearch.noResults- No results messagesearch.category.*- Category labels (sustantivo, verbo, adjetivo, etc.)
Word Page Translations
Word Page Translations
word.definition- Definition labelword.examples- Examples section titleword.synonyms- Synonyms labelword.related- Related words titleword.share- Share button text
Schema Translations
Schema Translations
schema.site.*- Site schema dataschema.faq.*- FAQ schema templates with variable interpolation
Usage Example
getLangFromUrl
Extracts the language code from a URL pathname.Parameters
URL object to extract language from
Returns
Language code - returns
"en" if the URL contains /en/, otherwise defaults to "es"Example
useTranslations
Creates a translation function for a specific language with variable interpolation support.Parameters
Language code (
"es" or "en"). Defaults to "es" for any value other than "en"Returns
Translation function that accepts:
key(string): Translation key to look upvars(object, optional): Variables to interpolate into the translation string using{variable}syntax
Example
Astro Component Usage
getLocalizedPath
Generates a localized URL path with the appropriate language prefix.Parameters
The path to localize (should start with
/)Language code (
"es" or "en")Returns
Path with language prefix:
/en{path} for English, /es{path} for Spanish