locale-match
A small library for matching a locale from a list of available locales to the user's preferred locales.
Examples
BCP 47
use best_matching_locale;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// "ru-UA" is the best match for the highest-priority user locale "ru-RU"
assert_eq!;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// "pt-BR" is the first best match for the highest-priority user locale "pt"
assert_eq!;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// Empty extended language subtag in "zh-Hans" matches any extended language, e.g. "cmn"
assert_eq!;
POSIX
use best_matching_locale;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// "ru_UA" is the best match for the highest-priority user locale "ru_RU"
assert_eq!;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// "pt_BR" is the first best match for the highest-priority user locale "pt"
assert_eq!;
let available_locales = vec!;
let user_locales = vec!;
let best_match = best_matching_locale;
// Empty territory in "fr.UTF-8" matches any territory, e.g. "CA"
assert_eq!;
License
This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this program. If not, see https://www.gnu.org/licenses/.
Copyright
2024 Petr Alexandrovich Sabanov
Metrics