Utility FunctionsLocales
isSameDialect
API Reference for the isSameDialect function
Overview
The isSameDialect function checks if multiple BCP-47 locale codes represent the same dialect without requiring a GT class instance.
Reference
Parameters
Prop
Type
Returns
boolean - true if all locale codes represent the same dialect
Examples
import { isSameDialect } from 'generaltranslation';
// Same dialect checks
console.log(isSameDialect('en-US', 'en-US')); // true
console.log(isSameDialect('en', 'en-US')); // true (base language matches regional)
console.log(isSameDialect('en-US', 'en-GB')); // false (different regions)
console.log(isSameDialect('en-US', 'es-ES')); // false (different languages)Notes
- Considers base languages as parents of regional variants
- Regional variants must match exactly
- Essential for locale fallback logic
- Accepts flexible input formats
- No external dependencies
Next Steps
- Use GT class method isSameDialect
- Compare languages with isSameLanguage
How is this guide?

