Skip to content

Add en-US locale#1222

Merged
AdrianAtZyte merged 8 commits intoscrapinghub:masterfrom
soksanichenko:master
Mar 25, 2026
Merged

Add en-US locale#1222
AdrianAtZyte merged 8 commits intoscrapinghub:masterfrom
soksanichenko:master

Conversation

@ghost
Copy link
Copy Markdown

@ghost ghost commented Feb 28, 2024

The code for English (United States) 'en-US'. The prefix, 'en', is a language code following the ISO 639-1 standard. The suffix, 'US', is a country code following the ISO 3166-1 Alpha-2 standard.
E.g. Discord uses that locale name for language English, US

soksanichenko and others added 4 commits February 28, 2024 15:20
The code for English (United States) 'en-US'. The prefix, 'en', is a language code following the ISO 639-1 standard. The suffix, 'US', is a country code following the ISO 3166-1 Alpha-2 standard.
@Gallaecio
Copy link
Copy Markdown
Contributor

Could you elaborate on why you are proposing this change? I think dateparser already uses “en-US” by default if you don’t specify a different country.

@soksanichenko
Copy link
Copy Markdown

soksanichenko commented May 22, 2025

Hello @Gallaecio
That's my PR, I really forgot about that.
I remember dataparser doesn't work properly if I use something like this

options = {'locales': ['en-US']}
dataparser.parse('12:00', **options

I will get error ValueError: Unknown locale(s): 'en-US'

@Gallaecio
Copy link
Copy Markdown
Contributor

But why would you set that locale? Does en not work as expected?

@soksanichenko
Copy link
Copy Markdown

soksanichenko commented May 23, 2025

That's just an example.
In my code I pass a locale as variable and don't know what's exactly locale it can be. Because of it I referred to Discord in the start post.
I mean it's legit locale and I think the dateparser should process it as rest others

@soksanichenko
Copy link
Copy Markdown

@Gallaecio Hello again :)

Any updates? How can I convince you in necessary of that PR?
I'm just still using the fork in my discord bot, because the discord sends en-US locale in an interaction if a user has English, US language in Discord settings.

Really appreciated for your attention.

@AdrianAtZyte
Copy link
Copy Markdown
Contributor

I tried to push a change to your branch but I could not. Can you add a test for the locale?

diff --git a/tests/test_loading.py b/tests/test_loading.py
index b79db98..96e6adf 100644
--- a/tests/test_loading.py
+++ b/tests/test_loading.py
@@ -190,6 +190,56 @@ class TestLoading(BaseTestCase):
                 ],
                 expected_locales=["shi-Latn", "teo-KE", "ewo", "vun"],
             ),
+            param(
+                given_languages=["en"],
+                given_locales=None,
+                given_region="US",
+                loaded_languages=[
+                    "en",
+                    "es",
+                    "fr",
+                    "ar",
+                    "asa",
+                    "nl",
+                    "so",
+                    "sr-Latn",
+                    "zgh",
+                    "pt",
+                    "zh-Hant",
+                    "zh-Hans",
+                    "ru",
+                    "ckb",
+                    "sq",
+                    "shi-Latn",
+                    "teo",
+                    "ewo",
+                    "vun",
+                ],
+                loaded_locales=[
+                    "en",
+                    "es",
+                    "fr",
+                    "fr-BF",
+                    "ar-SO",
+                    "asa",
+                    "nl-CW",
+                    "so-KE",
+                    "sr-Latn-XK",
+                    "zgh",
+                    "pt-MO",
+                    "zh-Hant-MO",
+                    "zh-Hans-MO",
+                    "ru-UA",
+                    "ckb-IR",
+                    "sq-XK",
+                    "shi-Latn",
+                    "teo-KE",
+                    "ewo",
+                    "vun",
+                    "en-US",
+                ],
+                expected_locales=["en-US"],
+            ),
         ]
     )
     def test_loading(

@soksanichenko
Copy link
Copy Markdown

Yeah, of course, I'll add it.

@soksanichenko
Copy link
Copy Markdown

@AdrianAtZyte Hello again.
I've added the new test and missed translation data for the locale.
Thank you.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (62710c0) to head (2d76d0f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1222   +/-   ##
=======================================
  Coverage   96.63%   96.63%           
=======================================
  Files         235      235           
  Lines        2915     2915           
=======================================
  Hits         2817     2817           
  Misses         98       98           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte AdrianAtZyte merged commit 7a3113e into scrapinghub:master Mar 25, 2026
15 checks passed
@AdrianAtZyte
Copy link
Copy Markdown
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants