Skip to content

Commit

Permalink
Fix typo in uk-ua language code (#62)
Browse files Browse the repository at this point in the history
* Fix typo in `uk-ua` language code

* Refactor `uk-uk` to `uk-ua`
  • Loading branch information
NeonDaniel authored Sep 7, 2023
1 parent a92f9a0 commit 08b11ea
Show file tree
Hide file tree
Showing 20 changed files with 17 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lang_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
- [sv-se](#sv)
- [fa-ir](#fa)
- [eu-eu](#eu)
- [uk-uk](#uk)
- [uk-ua](#uk)

### az

Expand Down
4 changes: 3 additions & 1 deletion lingua_franca/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import os
import re
from collections import namedtuple
from typing import List, Optional
from warnings import warn
from os.path import join

Expand Down Expand Up @@ -570,7 +571,8 @@ def nice_duration(duration, lang='', speech=True):
return out


def join_list(items, connector, sep=None, lang=''):
def join_list(items: List[str], connector: str, sep: Optional[str] = None,
lang: str = '') -> str:
""" Join a list into a phrase using the given connector word
Examples:
Expand Down
7 changes: 4 additions & 3 deletions lingua_franca/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@


_SUPPORTED_LANGUAGES = ("az", "ca", "cs", "da", "de", "en", "es", "fr", "hu",
"it", "nl", "pl", "pt", "ru", "sl", "sv", "fa", "eu", "uk")
"it", "nl", "pl", "pt", "ru", "sl", "sv", "fa", "eu",
"uk")

_SUPPORTED_FULL_LOCALIZATIONS = ("az-az", "ca-es", "cs-cz", "da-dk", "de-de",
"en-au", "en-us", "es-es", "fr-fr",
"hu-hu", "it-it", "nl-nl", "pl-pl",
"fa-ir", "pt-pt", "ru-ru", "sl-si",
"sv-se", "tr-tr", "eu-eu", "uk-uk")
"sv-se", "tr-tr", "eu-eu", "uk-ua")

_DEFAULT_FULL_LANG_CODES = {'az': 'az-az',
'ca': 'ca-es',
Expand All @@ -37,7 +38,7 @@
'sl': 'sl-si',
'sv': 'sv-se',
'tr': 'tr-tr',
'uk': 'uk-uk'}
'uk': 'uk-ua'}

__default_lang = None
__active_lang_code = None
Expand Down
2 changes: 1 addition & 1 deletion lingua_franca/lang/parse_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ def match_yes_or_no(text, lang):
words = json.load(f)
words = {k: [_.lower() for _ in v] for k, v in words.items()}
# after encoding information is lost
if lang == 'uk-uk':
if lang == 'uk-ua':
text = unicodedata.normalize('NFD', text)
else:
text = unicodedata.normalize('NFD', text) \
Expand Down
2 changes: 1 addition & 1 deletion lingua_franca/lang/parse_uk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1643,7 +1643,7 @@ def extract_numbers_uk(text, short_scale=True, ordinals=False):


class UkrainianNormalizer(Normalizer):
with open(resolve_resource_file("text/uk-uk/normalize.json"), encoding='utf8') as f:
with open(resolve_resource_file("text/uk-ua/normalize.json"), encoding='utf8') as f:
_default_config = json.load(f)


Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 7 additions & 7 deletions test/unittests/test_format_uk.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@


def setUpModule():
load_language("uk-uk")
load_language("uk-ua")
set_default_lang("uk")


Expand Down Expand Up @@ -75,15 +75,15 @@ def tearDownModule():
}

def setUpModule():
load_language("uk-uk")
load_language("uk-ua")
set_default_lang("uk")

class TestNiceNumberFormat(unittest.TestCase):
load_language("uk-uk")
load_language("uk-ua")
set_default_lang("uk")

def test_convert_float_to_nice_number(self):
load_language("uk-uk")
load_language("uk-ua")
set_default_lang("uk")
for number, number_str in NUMBERS_FIXTURE_UK.items():
self.assertEqual(nice_number(number, speech=True), number_str,
Expand Down Expand Up @@ -462,7 +462,7 @@ def test_convert_times(self):
"без четверті друга година")

def test_nice_date(self):
lang = "uk-uk"
lang = "uk-ua"
i = 1
print(self.test_config[lang]["test_nice_date"].get(str(i)))
while (self.test_config[lang].get("test_nice_date") and
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_nice_date(self):
self.assertTrue(len(nice_date(dt, lang=lang)) > 0)

def test_nice_date_time(self):
lang = "uk-uk"
lang = "uk-ua"
i = 1
while (self.test_config[lang].get("test_nice_date_time") and
self.test_config[lang]["test_nice_date_time"].get(str(i))):
Expand All @@ -514,7 +514,7 @@ def test_nice_date_time(self):
i = i + 1

def test_nice_year(self):
lang = "uk-uk"
lang = "uk-ua"
i = 1
while (self.test_config[lang].get("test_nice_year") and
self.test_config[lang]["test_nice_year"].get(str(i))):
Expand Down

0 comments on commit 08b11ea

Please sign in to comment.