Internationalization and Localization

The Locale API allows setting i18n and l7n options globally for the components.

Configuration is managed by the Locale API imported from primereact/api.


import { locale, addLocale, updateLocaleOption, updateLocaleOptions, localeOption, localeOptions } from 'primereact/api';
         

An available locale can be set with locale method at anytime.


locale('en');
         

New locale settings can be added using addLocale method.


addLocale('es', {
    firstDayOfWeek: 1,
    dayNames: ['domingo', 'lunes', 'martes', 'miércoles', 'jueves', 'viernes', 'sábado'],
    dayNamesShort: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'],
    dayNamesMin: ['D', 'L', 'M', 'X', 'J', 'V', 'S'],
    monthNames: ['enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'],
    monthNamesShort: ['ene', 'feb', 'mar', 'abr', 'may', 'jun', 'jul', 'ago', 'sep', 'oct', 'nov', 'dic'],
    today: 'Hoy',
    clear: 'Limpiar',
    //...
});
         

Ready to use settings for locales are available at the community supported PrimeLocale repository. We'd appreciate if you could contribute to this repository with pull requests and share it with the rest of the community.

Configuration is managed by the Locale API imported from primereact/api.

Locale Methods

NameParametersDescription
localecurrentLocale: stringSets the current locale if installed.
addLocalelocale: string,
options: object
Installs a new locale.
updateLocaleOptionkey: string,
value: any,
locale: string
Changes the specific option value of a locale.
updateLocaleOptionsoptions: object,
locale: string
Changes the option values of a locale.
localeOptionkey: string,
locale: string
Return the value of a specific locale option.
localeOptionslocale: stringReturns the values of locale options.

Locale Options

KeyValue
startsWithStarts with
containsContains
notContainsNot contains
endsWithEnds with
equalsEquals
notEqualsNot equals
noFilterNo Filter
filterFilter
ltLess than
lteLess than or equal to
gtGreater than
gteGreater than or equal to
dateIsDate is
dateIsNotDate is not
dateBeforeDate is before
dateAfterDate is after
customCustom
clearClear
applyApply
matchAllMatch All
matchAnyMatch Any
addRuleAdd Rule
removeRuleRemove Rule
acceptYes
rejectNo
chooseChoose
uploadUpload
cancelCancel
closeClose
dayNames['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday']
dayNamesShort['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
dayNamesMin['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']
monthNames['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
monthNamesShort['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
todayToday
weekHeaderWk
firstDayOfWeek0
dateFormatmm/dd/yy
weakWeak
mediumMedium
strongStrong
passwordPromptEnter a password
emptyFilterMessageNo available options
emptyMessageNo results found
aria.trueLabelTrue
aria.falseLabelFalse
aria.nullLabelNot Selected
aria.pageLabelPage
aria.firstPageLabelFirst Page
aria.lastPageLabelLast Page
aria.nextPageLabelNext Page
aria.previousPageLabelPrevious Page
aria.selectLabelSelect
aria.unselectLabelUnselect
aria.expandLabelExpand
aria.collapseLabelCollapse