PrimeLocale provides i18n and l7n options globally for the components in PrimeUI libraries.
npm install primelocale
!NPM Downloads


Using npm
npm install primelocale
Using yarn
yarn add primelocale
Using pnpm
pnpm add primelocale
`
$3
- PrimeReact Sandbox
- PrimeVue Sandbox
primelocale now ships with JavaScript files that export the locale as well.
`js
import { all } from "primelocale";
import { de } from "primelocale/js/de.js";
import { en } from "primelocale/js/en.js";
import { ja } from "primelocale/js/ja.js";
all.ky.aria.collapseLabel;
de.aria.collapseLabel;
en.aria.collapseLabel;
ja.aria.collapseLabel;
`
- If you are using TypeScript, all files have appropriate typings.
- We ship both an ESM and a CJS version. If you are still using CJS
and your environment does not support the exports field in the package.json,
you may need to import the individual language files directly from
primelocale/cjs/de.js instead.
Default Locale Options
| Key | Value
| --- | ---
| accept | Yes
| addRule | Add Rule
| am | am
| apply | Apply
| cancel | Cancel
| choose | Choose
| chooseDate | Choose Date
| chooseMonth | Choose Month
| chooseYear | Choose Year
| clear | Clear
| completed | Completed
| contains | Contains
| custom | Custom // only available for PrimeReact
| dateAfter | Date is after
| dateBefore | Date is before
| dateFormat | mm/dd/yy
| dateIs | Date is
| dateIsNot | Date is not
| dayNames | ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
| dayNamesMin | ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"]
| dayNamesShort | ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
| emptyFilterMessage | No results found // @deprecated Use "emptySearchMessage" option instead.
| emptyMessage | No available options
| emptySearchMessage | No results found
| emptySelectionMessage | No selected item
| endsWith | Ends with
| equals | Equals
| fileChosenMessage | {0} files
| fileSizeTypes | ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
| filter | Filter // only available for PrimeReact
| firstDayOfWeek | 0
| gt | Greater than
| gte | Greater than or equal to
| lt | Less than
| lte | Less than or equal to
| matchAll | Match All
| matchAny | Match Any
| medium | Medium
| 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"]
| nextDecade | Next Decade
| nextHour | Next Hour
| nextMinute | Next Minute
| nextMonth | Next Month
| nextSecond | Next Second
| nextYear | Next Year
| noFileChosenMessage | No file chosen
| noFilter | No Filter
| notContains | Not contains
| notEquals | Not equals
| now | Now
| passwordPrompt | Enter a password
| pending | Pending
| pm | pm
| prevDecade | Previous Decade
| prevHour | Previous Hour
| prevMinute | Previous Minute
| prevMonth | Previous Month
| prevSecond | Previous Second
| prevYear | Previous Year
| reject | No
| removeRule | Remove Rule
| searchMessage | {0} results are available
| selectionMessage | {0} items selected
| showMonthAfterYear | false
| startsWith | Starts with
| strong | Strong
| today | Today
| upload | Upload
| weak | Weak
| weekHeader | Wk
| aria.cancelEdit | Cancel Edit
| aria.close | Close
| aria.collapseLabel | Collapse
| aria.collapseRow | Row Collapsed
| aria.editRow | Edit Row
| aria.expandLabel | Expand
| aria.expandRow | Row Expanded
| aria.falseLabel | False
| aria.filterConstraint | Filter Constraint
| aria.filterOperator | Filter Operator
| aria.firstPageLabel | First Page
| aria.gridView | Grid View
| aria.hideFilterMenu | Hide Filter Menu
| aria.jumpToPageDropdownLabel | Jump to Page Dropdown
| aria.jumpToPageInputLabel | Jump to Page Input
| aria.lastPageLabel | Last Page
| aria.listLabel | Option List
| aria.listView | List View
| aria.maximizeLabel | Maximize
| aria.minimizeLabel | Minimize
| aria.moveAllToSource | Move All to Source
| aria.moveAllToTarget | Move All to Target
| aria.moveBottom | Move Bottom
| aria.moveDown | Move Down
| aria.moveToSource | Move to Source
| aria.moveToTarget | Move to Target
| aria.moveTop | Move Top
| aria.moveUp | Move Up
| aria.navigation | Navigation
| aria.next | Next
| aria.nextPageLabel | Next Page
| aria.nullLabel | Not Selected
| aria.pageLabel | Page {page}
| aria.passwordHide | Password Hide
| aria.passwordShow | Password Show
| aria.previous | Previous
| aria.prevPageLabel | Previous Page
| aria.removeLabel | Remove
| aria.rotateLeft | Rotate Left
| aria.rotateRight | Rotate Right
| aria.rowsPerPageLabel | Rows per page
| aria.saveEdit | Save Edit
| aria.scrollTop | Scroll Top
| aria.selectAll | All items selected
| aria.selectColor | Select a color
| aria.selectLabel | Select
| aria.selectRow | Row Selected
| aria.showFilterMenu | Show Filter Menu
| aria.slide | Slide
| aria.slideNumber | {slideNumber}
| aria.star | 1 star
| aria.stars | {star} stars
| aria.trueLabel | True
| aria.unselectAll | All items unselected
| aria.unselectLabel | Unselect
| aria.unselectRow | Row Unselected
| aria.zoomImage | Zoom Image
| aria.zoomIn | Zoom In
| aria.zoomOut | Zoom Out
Adding New Values
To add a new value to the translation files, follow these steps:
1. Add to en.json: First, add the new key-value pair to the en.json file. This file serves as the source for all translations.
2. Obtain Google Translate API Key: You'll need a Google Translate API key to run the translation script. If you don't have one, follow Google's instructions to obtain an API key.
3. Update script-translate.js: Once you have the API key, update the script-translate.js file. Locate the following line and replace 'REPLACEME' with your actual API key:
`js
const apiKey = 'REPLACEME'; // Replace with your API key
`
Note: Be careful not to commit this change to version control to keep your API key private.
4. Run the Translation Script: After adding your new key to en.json and updating the API key, run the translation script:
`bash
node script-translate.js
`
This script will:
- Read all language JSON files
- Identify the new key(s) added to en.json
- Translate the new value(s) to all other languages
- Update all language files with the new translations
5. Review Translations: After running the script, it's a good practice to review the generated translations for accuracy.
By following these steps, you ensure that new values are consistently added and translated across all language files in your project.
Publishing
Adjust the version in the package.json if necessary, then
`bash
npm login
This will run npm run build automatically
npm publish --access public
``