Zephora UI

การแปลภาษา

ข้อความ UI ในตัวทุกชิ้น (ปุ่มปิด, ป้ายเพจจิเนชัน, การประกาศการเรียงลำดับ, ข้อความอัปโหลด…) จะถูกแปลงผ่าน locale registry มีเพียง en เท่านั้นที่ฝังอยู่ในบันเดิล — ภาษาอื่นทุกภาษาจะถูกโหลดจากภายนอก (โมดูลที่ import ได้หรือไฟล์ JSON) แล้วลงทะเบียนด้วย addLocale registry เดียวกันนี้ขับเคลื่อนทั้ง @zephora/react และ @zephora/native en, tr.

การโหลด locale

// 1) As a module (tree-shaken, typed):
import { addLocale } from "@zephora/react";
import { trLocale } from "@zephora/theme/locales/tr";
addLocale("tr", trLocale);

// 2) As JSON over the network (e.g. from your CDN):
const messages = await fetch("/locales/tr.json").then((r) => r.json());
addLocale("tr", messages);
// JSON dosyası pakette hazır: @zephora/theme/locales/tr.json

เดโมสด

สลับ locale — ป้ายเพจจิเนชันและปุ่มของ dialog จะอัปเดตทันที

การเลือก locale

// Web
<ZephoraConfigProvider locale="tr">...</ZephoraConfigProvider>

// React Native
<ZephoraProvider theme={lightTheme} locale="tr">...</ZephoraProvider>

การลงทะเบียน locale ที่กำหนดเอง

addLocale จะรวมข้อความของคุณทับบนภาษาอังกฤษ ดังนั้นการนิยามเพียงบางส่วนจึงปลอดภัย updateLocale จะแพตช์ locale ที่มีอยู่แล้ว

import { addLocale, updateLocale } from "@zephora/react";

addLocale("de", {
  intlLocale: "de",
  firstDayOfWeek: 1,
  close: "Schließen",
  cancel: "Abbrechen",
  confirm: "Bestätigen",
  loading: "Wird geladen…",
  pageOf: "Seite {page} von {count}",
});

updateLocale("de", { clear: "Leeren" });

การอ่านข้อความในคอมโพเนนต์ของคุณเอง

import { useLocale, localeOption } from "@zephora/react";

function SaveBar() {
  const { t } = useLocale();
  return <Button>{t("apply")}</Button>;
}

// Outside React:
localeOption("cancel", "tr"); // "İptal"

locale ที่มีให้ใช้

มาพร้อมคำแปลสำเร็จรูป 48 ภาษา แต่ละภาษาเป็นโมดูลอิสระ — import เฉพาะที่คุณต้องการ (หรือ fetch ไฟล์ .json ที่ตรงกัน)

โค้ดภาษาเส้นทาง import
arالعربية (Arabic)@zephora/theme/locales/ar
azAzərbaycanca (Azerbaijani)@zephora/theme/locales/az
bgБългарски (Bulgarian)@zephora/theme/locales/bg
bnবাংলা (Bengali)@zephora/theme/locales/bn
caCatalà (Catalan)@zephora/theme/locales/ca
csČeština (Czech)@zephora/theme/locales/cs
daDansk (Danish)@zephora/theme/locales/da
deDeutsch (German)@zephora/theme/locales/de
elΕλληνικά (Greek)@zephora/theme/locales/el
esEspañol (Spanish)@zephora/theme/locales/es
etEesti (Estonian)@zephora/theme/locales/et
faفارسی (Persian)@zephora/theme/locales/fa
fiSuomi (Finnish)@zephora/theme/locales/fi
frFrançais (French)@zephora/theme/locales/fr
heעברית (Hebrew)@zephora/theme/locales/he
hiहिन्दी (Hindi)@zephora/theme/locales/hi
hrHrvatski (Croatian)@zephora/theme/locales/hr
huMagyar (Hungarian)@zephora/theme/locales/hu
hyՀայերեն (Armenian)@zephora/theme/locales/hy
idBahasa Indonesia (Indonesian)@zephora/theme/locales/id
isÍslenska (Icelandic)@zephora/theme/locales/is
itItaliano (Italian)@zephora/theme/locales/it
ja日本語 (Japanese)@zephora/theme/locales/ja
kaქართული (Georgian)@zephora/theme/locales/ka
kkҚазақша (Kazakh)@zephora/theme/locales/kk
ko한국어 (Korean)@zephora/theme/locales/ko
ltLietuvių (Lithuanian)@zephora/theme/locales/lt
lvLatviešu (Latvian)@zephora/theme/locales/lv
msBahasa Melayu (Malay)@zephora/theme/locales/ms
nlNederlands (Dutch)@zephora/theme/locales/nl
noNorsk bokmål (Norwegian)@zephora/theme/locales/no
plPolski (Polish)@zephora/theme/locales/pl
ptPortuguês (Portuguese)@zephora/theme/locales/pt
pt-brPortuguês do Brasil (Brazilian Portuguese)@zephora/theme/locales/pt-br
roRomână (Romanian)@zephora/theme/locales/ro
ruРусский (Russian)@zephora/theme/locales/ru
skSlovenčina (Slovak)@zephora/theme/locales/sk
slSlovenščina (Slovenian)@zephora/theme/locales/sl
srSrpski (Serbian)@zephora/theme/locales/sr
svSvenska (Swedish)@zephora/theme/locales/sv
swKiswahili (Swahili)@zephora/theme/locales/sw
taதமிழ் (Tamil)@zephora/theme/locales/ta
thไทย (Thai)@zephora/theme/locales/th
trTürkçe (Turkish)@zephora/theme/locales/tr
ukУкраїнська (Ukrainian)@zephora/theme/locales/uk
viTiếng Việt (Vietnamese)@zephora/theme/locales/vi
zh-cn简体中文 (Simplified Chinese)@zephora/theme/locales/zh-cn
zh-tw繁體中文 (Traditional Chinese)@zephora/theme/locales/zh-tw

อ้างอิงข้อความ

ชุดคีย์ทั้งหมดอยู่บนชนิด ZephoraLocale — การกระทำ (close, cancel, confirm, clear…), สถานะข้อมูล (loading, noData, emptyMessage), ข้อความฟอร์ม (showPassword, browseFiles, removeFile), การนำทาง (pageOf, nextPage, breadcrumb), การแสดงข้อมูล (sortAscending, selectAllRows, goToSlide) และวันที่ (prevMonth, chooseDate, firstDayOfWeek, intlLocale) ตัวยึดตำแหน่งใช้ไวยากรณ์ {param} ที่ถูกแทรกค่าด้วย t(key, params)