medhira-jst-functions
v0.0.1
Published
JavaScript/TypeScript utility functions for locale and language handling - Powered by MEDHIRA
Downloads
120
Maintainers
Readme
medhira-jst-functions
MEDHIRA JST Functions is a JavaScript/TypeScript utility package that provides functions for locale and language handling. It helps developers work with native language codes and related information.
Why MEDHIRA?
In modern applications, internationalization is key. MEDHIRA JST Functions provides:
- Locale Lookup - Find locale by language code
- Language Search - Search locales by language name
- Complete List - Access all available locales
- TypeScript Support - Full type definitions
- Zero Dependencies - Lightweight and fast
Installation
# NPM
npm install medhira-jst-functions
# React Native
npm install --save medhira-jst-functions
# Expo
npx expo install medhira-jst-functionsFunctions
getLocaleByCode
Get locale information by language code.
import { getLocaleByCode } from 'medhira-jst-functions';
console.log(getLocaleByCode('aa'));
// Output
{ id: 4096, language: 'Afar', location: null, tag: 'aa' }getLocaleList
Get all available locales.
import { getLocaleList } from 'medhira-jst-functions';
console.log(getLocaleList());
// Output: List of all available Languages with details
{
aa: { id: 4096, language: 'Afar', location: null, tag: 'aa' },
'aa-dj': { id: 4096, language: 'Afar', location: 'Djibouti', tag: 'aa-DJ' },
'aa-er': { id: 4096, language: 'Afar', location: 'Eritrea', tag: 'aa-ER' },
'aa-et': { id: 4096, language: 'Afar', location: 'Ethiopia', tag: 'aa-ET' },
...
}getLocaleByLanguage
Search locales by language name.
import { getLocaleByLanguage } from 'medhira-jst-functions';
console.log(getLocaleByLanguage('en'));
// Output: Returns the list of all tags ending with 'english'
[
{ id: 4096, language: 'English', location: 'World', tag: 'en-001' },
{ id: 9225, language: 'English', location: 'Caribbean', tag: 'en-029' },
{ id: 4096, language: 'English', location: 'Europe', tag: 'en-150' },
{ id: 19465, language: 'English', location: 'United Arab Emirates', tag: 'en-AE' },
...
]Use Cases
User Language Selection
import { getLocaleByCode, getLocaleByLanguage } from 'medhira-jst-functions';
// Get user's preferred language
const userLang = 'en-US';
const locale = getLocaleByCode(userLang);
if (typeof locale !== 'string') {
console.log(`Selected: ${locale.language} (${locale.location})`);
}Language Dropdown
import { getLocaleList } from 'medhira-jst-functions';
// Populate language dropdown
const locales = getLocaleList();
const languageOptions = Object.entries(locales).map(([code, info]) => ({
value: code,
label: `${info.language}${info.location ? ` (${info.location})` : ''}`
}));Search Languages
import { getLocaleByLanguage } from 'medhira-jst-functions';
// Search for Spanish locales
const spanishLocales = getLocaleByLanguage('Spanish');
console.log(spanishLocales);Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repository
- Create a feature branch
- Submit a pull request
Sponsor & Support
To keep this library maintained and up-to-date, please consider sponsoring it on GitHub.
Or, if you're looking for private support or help in customizing the experience, reach out to us at [email protected]
About MEDHIRA
MEDHIRA - Engineering Intelligence Across Everything
- Website: https://medhira.readthedocs.io/en/latest/
- GitHub: https://github.com/HELLOMEDHIRA
- Email: [email protected]
License
Apache-2.0
Made with passion by MEDHIRA
