Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ISO 3166-2 to identify the country and the subdivisions #388

Merged
merged 1 commit into from
Dec 6, 2023

Conversation

derTobsch
Copy link
Contributor

@derTobsch derTobsch commented Nov 28, 2023

closes #267

Todo:

  • translations

@derTobsch derTobsch marked this pull request as draft November 28, 2023 17:55
@derTobsch derTobsch force-pushed the 267-iso-3166-2 branch 2 times, most recently from 8d144f9 to 5d618d7 Compare November 28, 2023 19:48
@derTobsch derTobsch added this to the 0.22.0 milestone Nov 28, 2023
@derTobsch derTobsch force-pushed the 267-iso-3166-2 branch 5 times, most recently from d1d4c95 to 03fbfdb Compare December 6, 2023 12:21
@derTobsch derTobsch marked this pull request as ready for review December 6, 2023 12:21
@derTobsch derTobsch force-pushed the 267-iso-3166-2 branch 2 times, most recently from 926be47 to 8825f9c Compare December 6, 2023 12:37
Copy link

sonarcloud bot commented Dec 6, 2023

SonarCloud Quality Gate failed.    Quality Gate failed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

idea Catch issues before they fail your Quality Gate with our IDE extension sonarlint SonarLint

@derTobsch derTobsch merged commit e475260 into main Dec 6, 2023
10 of 11 checks passed
@derTobsch derTobsch deleted the 267-iso-3166-2 branch December 6, 2023 13:10
Copy link
Contributor

@XSpielinbox XSpielinbox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for these improvements!

Comment on lines +53 to +58
<dependency>
<groupId>com.vitorsvieira</groupId>
<artifactId>scala-iso_2.12</artifactId>
<version>0.1.2</version>
<scope>test</scope>
</dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unmaintained since 2017.

Did you take a look at com.neovisionaries » nv-i18n with sources available under https://github.com/TakahikoKawasaki/nv-i18n ? This seems unmaintained since 2021 however as well, but seems way more popular/established and there seems to be some discussion on continuing maintenance.

This is really a pity, as this information changes so frequently. Shouldn't many people in the need for something like this? Why is there nothing good for this or what am I missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I know that is unmaintained and a scala library. But I found no better solution atm for the ISO 3166-2 Codes. nv-i18n does not support 3166-2 or? I could find anything there https://github.com/TakahikoKawasaki/nv-i18n/tree/master/src/main/java/com/neovisionaries/i18n

I already thought about creating an own, but that would be much more to do as I am willing to do atm.

So I thought it is a good compromise to use this lib, only in test, so replace it later.

@@ -230,7 +252,6 @@ country.description.in.jh = Jhārkhand
country.description.in.jk = Jammu and Kashmīr
country.description.in.ka = Karnātaka
country.description.in.kl = Kerala
country.description.in.la = Ladākh
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this correct region code?
Having this would also be a requisite for #281 and I find it very confusing to have so many India subdivisions, but miss 2 of them. It is time intensive to find out, which one is missing.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe because they were not used in the xml files? Maybe it was a mistake? same for *.tg

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not use these subdivision codes in the india holiday file, that is why I deleted it. We could add it again, but would not make any difference atm. I think if we want to support Ladākh, we can do that in that pr.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, they are currently not used in the XML files, as the only special holidays for these regions are not yet supported, but all other holidays of India of course apply to them to.

e.g. Tasman (nz.tas) has an empty holiday list as well, but is listed and e.g. Andorra (ad) is also listed without having any reference in the XML files. I thought that it would be a good first step to complete the country list, that one knows what is there and what is missing and then complete the exact holidays afterwards, but that at least all regions can already be selected.

Copy link
Contributor Author

@derTobsch derTobsch Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I see what you mean. We can add them with an empty list, that is fine for me. We should create a small "guide" like "how we work" and list these decisions in the readme.

Did you try what is happening if you request the public holidays of in.la? What does jollyday return?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm I see what you mean. We can add them with an empty list, that is fine for me. We should create a small "guide" like "how we work" and list these decisions in the readme.

Yes, that sound's like a good idea! :)

Did you try what is happening if you request the public holidays of in.la? What does jollyday return?

No, I didn't try it yet - I will once I find the time. Though, now that it is removed everywhere, it is probably not very interesting, as it will almost for sure bring up some error. The more interesting scenarios to me are for codes that are listed in the .properties, but not the .xml or vice versa.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try what is happening if you request the public holidays of in.la? What does jollyday return?

So: With the released version 0.22.0 I noticed the following:
When I try to get the Name of a subdivision that is not listed in the .xml with holidayManager.getCalendarHierarchy().getChildren().get("<subdevision-code>").getDescription() I receive the following error:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "de.focus_shift.jollyday.core.CalendarHierarchy.getDescription()" because the return value of "java.util.Map.get(Object)" is null
When I try to get the holidays of a subdivision that is not declared in the .xml, it just outputs nothing. For both it thereby is not relevant, whether it is listed in the country_descriptions.properties. I however believe, that the country codes should be a superset of the defined holiday regions, as it is just confusing otherwise and the .properties file entries are relevant for localization and errors therein therefore more difficult to find.

I therefore come to the conclusion: every possible code should have a name in the country_descriptions.properties already. Every subdivision without special holidays must be listed in the respective xml file with a designated, empty SubConfigurations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see #430

@@ -243,7 +264,6 @@ country.description.in.pb = Punjab
country.description.in.py = Puducherry
country.description.in.rj = Rājasthān
country.description.in.sk = Sikkim
country.description.in.tg = Telangāna
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove this region code?
I find it very confusing to have so many India subdivisions, but miss 2 of them. It is time intensive to find out, which one is missing.

I just noticed however that on the 23rd of November the subdivision codes where now changed again and IN-OR is now IN-OD, IN-CT is IN-CG, IN-TG is IN-TS and IN-UT is IN-UK now. I will open a PR to fix this again as soon as possible.

See https://www.iso.org/obp/ui/#iso:code:3166:IN and https://en.wikipedia.org/wiki/ISO_3166-2:IN

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.

Breaking: make country codes ISO 3166 conformant
2 participants