Skip to content

Instantly share code, notes, and snippets.

@hleinone
Last active October 27, 2022 09:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hleinone/d1684884e80bbc065502b7327ad3d9ea to your computer and use it in GitHub Desktop.
Save hleinone/d1684884e80bbc065502b7327ad3d9ea to your computer and use it in GitHub Desktop.
Dart localized String to upper & lower case, supporting Turkish & Azerbaijani dotted 'i' & dotless 'ı' capitalization & decapitalization.
import 'dart:ui';
extension StringLocalizedCase on String {
String toLocalizedUpperCase(Locale locale) {
if (locale.languageCode == 'tr' || locale.languageCode == 'az') {
return replaceAll('i', 'İ').replaceAll('ı', 'I').toUpperCase();
}
return toUpperCase();
}
String toLocalizedLowerCase(Locale locale) {
if (locale.languageCode == 'tr' || locale.languageCode == 'az') {
return replaceAll('İ', 'i').replaceAll('I', 'ı').toLowerCase();
}
return toLowerCase();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment