Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

primelocale

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

primelocale

PrimeLocale provides i18n and l7n options globally for the components in PrimeUI libraries.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
6.2K
increased by16.83%
Maintainers
0
Weekly downloads
 
Created
Source

npm version NPM Downloads License: MIT primelocale

Internationalization and Localization

The Locale API allows setting i18n and l7n options globally for the components. You can import json files in this repo and use them in the locale API in the Prime UI libraries.

Prime UI libraries only provide English translations by default, if you"d like to share translations, please contribute to this repo.

Download

PrimeLocale is available at npm.

# Using npm
npm install primelocale

# Using yarn
yarn add primelocale

# Using pnpm
pnpm add primelocale

JavaScript Usage

When copying the local file to use, it is advisable to remove the object key in the json. For example, instead of having

{
"en":
    {
    ...
    }
}

Use:

{
...
}

Default Locale Options

KeyValue
acceptYes
addRuleAdd Rule
amam
applyApply
cancelCancel
chooseChoose
chooseDateChoose Date
chooseMonthChoose Month
chooseYearChoose Year
clearClear
completedCompleted
containsContains
customCustom // only available for PrimeReact
dateAfterDate is after
dateBeforeDate is before
dateFormatmm/dd/yy
dateIsDate is
dateIsNotDate 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"]
emptyFilterMessageNo results found // @deprecated Use "emptySearchMessage" option instead.
emptyMessageNo available options
emptySearchMessageNo results found
emptySelectionMessageNo selected item
endsWithEnds with
equalsEquals
fileSizeTypes["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"],
filterFilter // only available for PrimeReact
firstDayOfWeek0
gtGreater than
gteGreater than or equal to
ltLess than
lteLess than or equal to
matchAllMatch All
matchAnyMatch Any
mediumMedium
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"]
nextDecadeNext Decade
nextHourNext Hour
nextMinuteNext Minute
nextMonthNext Month
nextSecondNext Second
nextYearNext Year
noFilterNo Filter
notContainsNot contains
notEqualsNot equals
nowNow
passwordPromptEnter a password
pendingPending
pmpm
prevDecadePrevious Decade
prevHourPrevious Hour
prevMinutePrevious Minute
prevMonthPrevious Month
prevSecondPrevious Second
prevYearPrevious Year
rejectNo
removeRuleRemove Rule
searchMessage{0} results are available
selectionMessage{0} items selected
showMonthAfterYearfalse
startsWithStarts with
strongStrong
todayToday
uploadUpload
weakWeak
weekHeaderWk
aria.cancelEditCancel Edit
aria.closeClose
aria.collapseLabelCollapse
aria.collapseRowRow Collapsed
aria.editRowEdit Row
aria.expandLabelExpand
aria.expandRowRow Expanded
aria.falseLabelFalse
aria.filterConstraintFilter Constraint
aria.filterOperatorFilter Operator
aria.firstPageLabelFirst Page
aria.gridViewGrid View
aria.hideFilterMenuHide Filter Menu
aria.jumpToPageDropdownLabelJump to Page Dropdown
aria.jumpToPageInputLabelJump to Page Input
aria.lastPageLabelLast Page
aria.listViewList View
aria.moveAllToSourceMove All to Source
aria.moveAllToTargetMove All to Target
aria.moveBottomMove Bottom
aria.moveDownMove Down
aria.moveToSourceMove to Source
aria.moveToTargetMove to Target
aria.moveTopMove Top
aria.moveUpMove Up
aria.navigationNavigation
aria.nextNext
aria.nextPageLabelNext Page
aria.nullLabelNot Selected
aria.pageLabelPage {page}
aria.passwordHidePassword Hide
aria.passwordShowPassword Show
aria.previousPrevious
aria.previousPageLabelPrevious Page
aria.removeLabelRemove
aria.rotateLeftRotate Left
aria.rotateRightRotate Right
aria.rowsPerPageLabelRows per page
aria.saveEditSave Edit
aria.scrollTopScroll Top
aria.selectAllAll items selected
aria.selectLabelSelect
aria.selectRowRow Selected
aria.showFilterMenuShow Filter Menu
aria.slideSlide
aria.slideNumber{slideNumber}
aria.star1 star
aria.stars{star} stars
aria.trueLabelTrue
aria.unselectAllAll items unselected
aria.unselectLabelUnselect
aria.unselectRowRow Unselected
aria.zoomImageZoom Image
aria.zoomInZoom In
aria.zoomOutZoom 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:

    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:

    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

npm login
# This will run npm run build automatically
npm publish --access public

Then upload code to github, create tag & release.

License

Licensed under the MIT License.

Keywords

FAQs

Package last updated on 19 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc