-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ed55cf
commit 25ca61d
Showing
16 changed files
with
195 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,7 @@ | ||
import PrimeReact from './components/api/PrimeReact'; | ||
|
||
export default PrimeReact; | ||
export * from './components/api/Locale'; | ||
export * from './components/menuitem/MenuItem'; | ||
export * from './components/selectitem/SelectItem'; | ||
export * from './components/treenode/TreeNode'; | ||
export * from './components/treenode/TreeNode'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./components/api/PrimeReact'); | ||
module.exports = require('./components/api/Locale'); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import PrimeReact from './PrimeReact'; | ||
|
||
let locales = { | ||
'en': { | ||
accept: 'Yes', | ||
reject: 'No', | ||
choose: 'Choose', | ||
upload: 'Upload', | ||
cancel: 'Cancel', | ||
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'], | ||
today: 'Today', | ||
clear: 'Clear', | ||
weekHeader: 'Wk', | ||
firstDayOfWeek: 0, | ||
dateFormat: 'mm/dd/yy', | ||
weak: 'Weak', | ||
medium: 'Medium', | ||
strong: 'Strong', | ||
passwordPrompt: 'Enter a password' | ||
} | ||
}; | ||
|
||
function locale(locale) { | ||
if (locale) { | ||
PrimeReact.locale = locale; | ||
} | ||
|
||
return { | ||
locale: PrimeReact.locale, | ||
options: locales[PrimeReact.locale] | ||
} | ||
} | ||
|
||
function addLocale(locale, options) { | ||
locales[locale] = { ...locales['en'], ...options }; | ||
} | ||
|
||
function updateLocaleOption(key, value, locale) { | ||
localeOptions(locale)[key] = value; | ||
} | ||
|
||
function updateLocaleOptions(options, locale) { | ||
const _locale = locale || PrimeReact.locale; | ||
locales[_locale] = { ...locales[_locale], ...options }; | ||
} | ||
|
||
function localeOption(key, locale) { | ||
try { | ||
return localeOptions(locale)[key]; | ||
} | ||
catch(error) { | ||
throw new Error(`The ${key} option is not found in the current locale('${locale || PrimeReact.locale}').`); | ||
} | ||
} | ||
|
||
function localeOptions(locale) { | ||
const _locale = locale || PrimeReact.locale; | ||
return locales[_locale]; | ||
} | ||
|
||
export { locale, addLocale, updateLocaleOption, updateLocaleOptions, localeOption, localeOptions }; |
2 changes: 2 additions & 0 deletions
2
src/components/utils/PrimeReact.js → src/components/api/PrimeReact.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
export default class PrimeReact { | ||
|
||
static ripple = false; | ||
|
||
static locale = 'en'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.