Localization
The library ships English and Arabic for its built-in control strings (the "Close", "Clear selection", "Empty", and move-button labels inside components). Provide a config at the root of your app to switch locale; every component that reads a built-in string also keeps its own label prop, so a provider is only the default source.
Providing a config
<script setup lang="ts">
import { createConfig, provideMyGhfConfig } from '@myghf/ui'
provideMyGhfConfig(createConfig({ locale: 'ar' }))
</script>createConfig picks the label set for the locale's base language (ar-EG → ar), falling back to English, and merges any labels you pass on top:
const config = createConfig({
locale: 'ar-EG',
labels: { close: 'إغلاق النافذة' }, // overrides just this string
})| Export | Purpose |
|---|---|
createConfig(options?) | Builds a MyGhfConfig ({ locale, labels }). |
provideMyGhfConfig(config) | Provides it to the component tree (and returns it). |
useMyGhfConfig() | Reads the nearest config, or the English default outside a provider. |
myghfConfigKey | The injection key, if you prefer provide/inject directly. |
defaultConfig | The English default. |
Built-in labels
These are the strings currently read from the config (English / Arabic):
| Key | English | Arabic |
|---|---|---|
close | Close | إغلاق |
clear | Clear | مسح |
clearSelection | Clear selection | مسح التحديد |
togglePasswordVisibility | Toggle password visibility | إظهار كلمة المرور |
showOptions | Show options | عرض الخيارات |
empty | Empty | لا توجد عناصر |
moveSelectedToTarget | Move selected to target | نقل المحدد إلى الوجهة |
moveSelectedToSource | Move selected to source | نقل المحدد إلى المصدر |
moveAllToTarget | Move all to target | نقل الكل إلى الوجهة |
moveAllToSource | Move all to source | نقل الكل إلى المصدر |
drawerTitle | Drawer | لوحة جانبية |
formErrorsTitle | Please fix the following: | يرجى تصحيح ما يلي: |
emptyResults | No results | لا توجد نتائج |
loading | Loading… | جارٍ التحميل… |
selectAllRows | Select all rows | تحديد كل الصفوف |
selectRow | Select row | تحديد الصف |
selected | selected | محدد |
toggleRow | Toggle row | تبديل الصف |
search | Search | بحث |
searchPlaceholder | Search… | بحث… |
noResultsMatchFilters | No results match your filters | لا توجد نتائج مطابقة لعوامل التصفية |
clearFilters | Clear filters | مسح عوامل التصفية |
typeACommand | Type a command… | اكتب أمرًا… |
searchCommands | Search commands | بحث في الأوامر |
commandPalette | Command palette | لوحة الأوامر |
commandPaletteDescription | Search for and run a command. | ابحث عن أمر وشغّله. |
dropFilesPrompt | Drag and drop files here, or | اسحب وأفلت الملفات هنا، أو |
browse | browse | تصفح |
remove | Remove | إزالة |
rowsPerPage | Rows per page | صفوف لكل صفحة |
of | of | من |
previousPage | Previous page | الصفحة السابقة |
nextPage | Next page | الصفحة التالية |
Label props that have a config key (e.g. DataTable's emptyLabel, TablePagination's previousLabel, CommandPalette's title, FileUpload's prompt) default to the config label; set the prop to override. A few props without a config key (e.g. Tag's removeLabel) stay prop-only.
Direction and fonts
Localization and direction are separate concerns: set dir="rtl" and the Arabic font stack at the edge of an RTL subtree — see RTL & bilingual. Setting locale: 'ar' changes the strings, not the direction.
Number and date formatting
DatePicker, TimePicker, and InputNumber format through the config's locale: the locale prop wins, then the provider's locale, then the runtime locale. So a config with locale: 'ar' localizes their dates, times, and numbers without per-component props. The formatLocalizedDate / formatLocalizedTime / browserLocale helpers and the number utilities cover the rest.
