Last active
October 27, 2022 09:39
-
-
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.
This file contains hidden or 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
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