takahikokawasaki / nv-i18n Goto Github PK
View Code? Open in Web Editor NEWPackage to support internationalization, containing ISO 3166-1 country code enum, ISO 639-1 language code enum, etc.
License: Apache License 2.0
Package to support internationalization, containing ISO 3166-1 country code enum, ISO 639-1 language code enum, etc.
License: Apache License 2.0
I just ran into an issue which I eventually tracked down to the unicode character used in Aland Islands
:
AX("\u212Bland Islands", "ALA", 248, Assignment.OFFICIALLY_ASSIGNED),
CountryCode
uses Angstrom Sign, but according to wiktionary, \u00C5
appears to be the correct character (not \u212B
), so I think Latin Capital Letter A With Ring Above should be used instead.
http://en.wikipedia.org/wiki/ISO_4217
Do you plan to add CurrencyCode support? I found this example that uses your CountryCode:
http://blog.noblemaster.com/2012/11/01/iso-4217-currency-list-currency-java/
May be this would be interesting for you.
The country Serbia and Montenegro does not exist any more since 2006.
See https://en.wikipedia.org/wiki/Serbia_and_Montenegro
The code CS should therefore be removed, since the enum does not include formerly assigned codes.
Hello!
At the moment there are three languages in Norway - Bokmål, Nynorsk and Samisk.
LocaleCode in 1.7 version for Norwegian Bokmål language is no_NO, nn_NO for nynorsk (this is correct) and doesn't exist for samisk.
At the moment the correct locale for Bokmål is nb_NO, so please change from no_NO to nb_NO if possible.
Proofs you can find here:
https://bugzilla.redhat.com/show_bug.cgi?id=532487
and here (Norwegian, but idea is clear from table)
http://i18n.skolelinux.no/localekoder.txt
I would like that CountryCode implements some 'Region' interface. This would make it possible to make more implementations, like e.g. 'former countries' (I'm setting up something at https://github.com/mihxil/i18n-formerly-assigned).
I suggest something like this:
https://github.com/mihxil/nv-i18n/blob/master/src/main/java/com/neovisionaries/i18n/Region.java
How would you feel about something like this?
Northern Ireland has a new country code (XI) starting 1st January 2021.
Refer: https://tulli.fi/en/-/brexit-and-country-codes-from-1-january-2021-
It would be good to add XI to the list of country codes soon - as businesses have started incorporating this change.
The concept of an unknown CurrencyCode or CountryCode is much better represented as Optional.empty() or null.
The documentation would benefit from a mention that these values exist and the motivation for adding them. It will be a surprise to most users of these enumerations that the UNDEFINED value exists.
Hi!
Do you guys plan to add a support for cryptocurrencies like BTC, ETH, BCH and so on?
people in Hong Kong speak and read english :(
In https://github.com/TakahikoKawasaki/nv-i18n/blob/master/src/main/java/com/neovisionaries/i18n/LanguageAlpha3Code.java#L4536
the name is wrong, it should be Romanian (as denoted in the wikipedia page linked above the definition)
Correct obsolete currency codes
Two new methods perhaps :
public static List<CountryCode> findByName(String regex, boolean lc) {
..
public static List<CountryCode> findByName(Pattern pattern, boolean lc)
...
if (pattern.matcher(entry.getName()).matches())
To something like:
if (lc && pattern.matcher(entry.getName().toLowerCase()).matches()||!lc && pattern.matcher(entry.getName()).matches() )
Some developers have had the brilliant idea of using non-standard and conflicting locale codes in their apps. The problem is that, in the case of es_LA
(according to ISO "Spanish for Laos", but actually used for "Spanish for Latin America").
I wouldn't file a bug here if it weren't because this is now quite spread and common practice (you'll get that from Facebook's API or in free software localization files).
On the one hand, special handling for this case could be added ("LA" is not Laos if preceded by "es"). On the other, "Latin America" is not a country, and as such it lacks 2-digit ISO code. But it does have a 3-digit UN M.49 supranational code.
I'm not sure what would be an appropiate way of handling this in nv-i18n. At the moment, I'm just getting around it by replacing "es_LA" by just "es" before feeding it to nv-18n.
Could you please make methods such as getByAlpha2Code
, getByAlpha3Code
etc. public?
e.g. If a value needs to be a valid ISO 3166-1 alpha-2 but not alpha-3 this would make it easier to check.
Currently, the value needs to be checked if the length has the appropriate length prior to calling getByCode
.
Thanks
86: AD("Andorra", "AND", 16, Assignment.OFFICIALLY_ASSIGNED),
Should be 20.
1198: MO("Macao", "MCO", 492, Assignment.OFFICIALLY_ASSIGNED),
Should be 446.
Source: http://en.wikipedia.org/wiki/ISO_3166-1.
This might sound pedantic,
but it is advised to change
public static CurrencyCode getByCode(String code, boolean caseSensitive)
//to
public static CurrencyCode getByCodeCaseSensitive(String code)
//or event better
public static CurrencyCode getByCodeIgnoreCase(String code)
public static CurrencyCode getByCode(String code) // exact. Doesn't ignore case
Why is this approach any better you ask?
Hello,
Looking at the countryCode I saw that for the value AN("Netherlands Antilles") alpha3Code is 4 char length so getByCode will never return it as segregation is done on code length (2,3 and 9).
Furthermore on wikipedia alpha3code allocated to AN is ANT (Transitional reservations)
see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3
It would be very useful (for me) if the following method was added to the CurrencyCode
enum
String getSymbol() {
// returns "$" for US dollar, "€" for Euro, etc.
}
It would be useful if one of the following were added:
ContinentCode
which lists all of the countries on that continent, orCountryCode
enum had a ContinentCode
fieldIf this is particularly burdensome I'm willing to put in the initial work to create the mapping – just let me know which implementation you prefer.
I want to use this library in an OSGi container, but it needs to contain some headers in the META-INF/manifest.mf file in order to do so.
Many important platforms are OSGi-based, such as Eclipse, Apache ServiceMix, Sling, and Glassfish.
Fortunately it is pretty easy to add this to your maven build. I'll work on a pull request.
EZ
which stands for Eurozone
is missing from the CountryCode
enum. (https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#EZ)
Could you add the old currency of the Russian Federation RUR (code:810, minorUtit: 2).
Some of the services return 'RUR', which causes NPE in our code
Hi,
My request could be a little bit out of scope but it will be nice to add mapping between IATA airport code and related country code. I suppose it could help to extend this liberally power. What do you think about it?
Thanks.
is there any for set priority in sendBinery()
?
for example i have a byte array with 10 Mb
size, and i used from sendBinery()
. Before this byte array is really sent and onFrameSent()
called , i want to send another byte array with just 1 byte
, how can i send second array with lower size before send first byte array, and do not wait to send a bigger byte array?
EEA( European Economic Area ) is missing in the list of country codes.
https://en.wikipedia.org/wiki/European_Economic_Area
This is the only discrepancy between CurrencyCode and java.util.Currency with regard to decimal places. Worth updating?
Could digitally signing the jarfile be optional?
Build of master branch fails due to signing failure because secret key "E3F58E5C" is not available:
derek@derek-lubuntu:~/Projects/nv-i18n.takahiko$ mvn clean install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.neovisionaries:nv-i18n:bundle:1.23-SNAPSHOT
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-site-plugin is missing. @ line 73, column 29
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO] Inspecting build with total of 1 modules...
[INFO] Installing Nexus Staging features:
[INFO] ... total of 1 executions of maven-deploy-plugin replaced with nexus-staging-maven-plugin
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Neo Visionaries Internationalization Package 1.23-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ nv-i18n ---
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:resources (default-resources) @ nv-i18n ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/derek/Projects/nv-i18n.takahiko/src/main/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ nv-i18n ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 7 source files to /home/derek/Projects/nv-i18n.takahiko/target/classes
[INFO]
[INFO] --- maven-resources-plugin:3.0.2:testResources (default-testResources) @ nv-i18n ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/derek/Projects/nv-i18n.takahiko/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ nv-i18n ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /home/derek/Projects/nv-i18n.takahiko/target/test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.20:test (default-test) @ nv-i18n ---
[INFO]
[INFO] -------------------------------------------------------
[INFO] T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.neovisionaries.i18n.ScriptCodeTest
[INFO] Tests run: 52, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.193 s - in com.neovisionaries.i18n.ScriptCodeTest
[INFO] Running com.neovisionaries.i18n.LanguageCodeTest
[INFO] Tests run: 121, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.276 s - in com.neovisionaries.i18n.LanguageCodeTest
[INFO] Running com.neovisionaries.i18n.CountryCodeTest
[INFO] Tests run: 41, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.052 s - in com.neovisionaries.i18n.CountryCodeTest
[INFO] Running com.neovisionaries.i18n.LocaleCodeTest
[INFO] Tests run: 45, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 s - in com.neovisionaries.i18n.LocaleCodeTest
[INFO] Running com.neovisionaries.i18n.CurrencyCodeTest
[INFO] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.048 s - in com.neovisionaries.i18n.CurrencyCodeTest
[INFO] Running com.neovisionaries.i18n.LanguageAlpha3CodeTest
[INFO] Tests run: 183, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.093 s - in com.neovisionaries.i18n.LanguageAlpha3CodeTest
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 459, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO]
[INFO] --- maven-bundle-plugin:2.5.3:bundle (default-bundle) @ nv-i18n ---
[INFO]
[INFO] --- maven-source-plugin:2.3:jar-no-fork (attach-sources) @ nv-i18n ---
[INFO] Building jar: /home/derek/Projects/nv-i18n.takahiko/target/nv-i18n-1.23-SNAPSHOT-sources.jar
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.1:jar (attach-javadocs) @ nv-i18n ---
[INFO]
Loading source files for package com.neovisionaries.i18n...
Constructing Javadoc information...
Standard Doclet version 1.8.0_131
Building tree for all the packages and classes...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/CountryCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/CountryCode.Assignment.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/CurrencyCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/LanguageAlpha3Code.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/LanguageAlpha3Code.Usage.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/LanguageCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/LocaleCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/ScriptCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/package-frame.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/package-summary.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/package-tree.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/constant-values.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/LocaleCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/ScriptCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/LanguageCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/LanguageAlpha3Code.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/LanguageAlpha3Code.Usage.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/CurrencyCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/CountryCode.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/class-use/CountryCode.Assignment.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/com/neovisionaries/i18n/package-use.html...
Building index for all the packages and classes...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/overview-tree.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/index-all.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/deprecated-list.html...
Building index for all classes...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/allclasses-frame.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/allclasses-noframe.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/index.html...
Generating /home/derek/Projects/nv-i18n.takahiko/target/apidocs/help-doc.html...
[INFO] Building jar: /home/derek/Projects/nv-i18n.takahiko/target/nv-i18n-1.23-SNAPSHOT-javadoc.jar
[INFO]
[INFO] --- maven-gpg-plugin:1.5:sign (sign-artifacts) @ nv-i18n ---
gpg: skipped "E3F58E5C": secret key not available
gpg: signing failed: secret key not available
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 12.933 s
[INFO] Finished at: 2017-08-17T16:26:13-04:00
[INFO] Final Memory: 22M/90M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.5:sign (sign-artifacts) on project nv-i18n: Exit code: 2 -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Trying to retrieve the Currency object for MRU throws a NullPointerException.
Code to recreate issue:
Currency currency = CurrencyCode.MRU.getCurrency();
Sorry, I need to take a look at it again.
Edit: Close the ticket please, your implementation seems to be flawless :)
Please support user-assigned country codes. For example, field Country Identifier in a Global Intermediary Identification Number supports country number 999 for "Other".
I think, be cool, if in CurrencyCode I can get displayName for currency on diffirent languages. I can give you Currencies names in Russian language and you can include properties-file in lib. My email: [email protected]. Send me and I give you properties-file for Russian language
Please, add a new currency code to be used in Belarus with the July 1, 2016.
Amendment Number 161:
http://www.currency-iso.org/dam/isocy/downloads/dl_currency_iso_amendment_161.pdf
The getCurrency()
method in com.neovisionaries.i18n.CountryCode
fails for CountryCode.EU
. The currency cannot be resolved for the locale Locale("", "EU")
and an exception gets thrown by the standard library.
import java.util.*;
class Main {
public static void main(String[] args) {
var l = new Locale("", "EU");
var c = Currency.getInstance(l);
println(c);
}
}
Exception in thread "main" java.lang.IllegalArgumentException
at java.base/java.util.Currency.getInstance(Currency.java:410)
at Main.main(currency.java:7)
Due to the exception handling, the call CurrencyCode.EU.getCurrency()
results with null
.
In country CG (Congo) must be currency XAF (CFA Franc BEAC) and AN (Netherlands Antilles) must be ANG (Netherlands Antillean Guilder)
What do you think about PhoneCode class? Maybe add to lib phone code and relation with countries?
The assignment
field on CountryCode is useful for working out if country codes are no longer used (eg just use the OFFICIALLY_ASSIGNED codes).
CurrencyCode has some javadoc @deprecated
markers but I think it would be better to have some explicit flag that can be checked in code.
Hi, there is no zh-TW (Chinese - Taiwan - CHT) code in the enum.
Below the link :
https://msdn.microsoft.com/zh-tw/library/ee825488(v=cs.20).aspx
Thank for great work!!
Error:(171, 13) Failed to resolve: com.neovisionaries:nv-i18n:1.21
Why like this ?
There is no AP (Asia/Pacific Region) code in the enum.
Why ?
CW("Cura/u00E7ao", "CUW", 531, Assignment.OFFICIALLY_ASSIGNED)
should be
CW("Cura\u00E7ao", "CUW", 531, Assignment.OFFICIALLY_ASSIGNED),
There are no entries in LocaleCode for kazakhstan at all. Would you mind adding kk_KZ and ru_KZ?
Very cool - can you add international telephone dial code?
US = 1
UK = 44
HK = 852
etc.
Hello!
I really like your library, but i'm lacking consistent Continent
support. What do you think about including such feature? I'm willing to implement it.
Hi! Correct me if I'm wrong but now it's not possible to reliably use the library in the modularized application. Because if I add the jar to the module path it becomes an automatic module and its name is derived from the jar name because there is no Automatic-Module-Name entry in the Manifest and that's something pretty fragile in case you rename the jar. So could you please add this entry?
The explicit label "Province of China" seems unnecessarily political. If I print the country name text as-is in my app I'm at risk of making it look like my app has a political opinion.
It's mildly annoying having to filter this bit of text out. How about we change the text to simply "Taiwan"?
Now for get display country name i must wite something like this:
String countryName = new Locale("", countryCode).getDisplayCountry(systemConfig.getLocale());
In JDK class Locale there is translates country names for some languages (English, Russian), but not all.
I use CountryCode, but for display country name i must use class Locale.
ISO 3166-2 defines the subdivisions of ISO 3166-1 (which defines countries): http://en.wikipedia.org/wiki/ISO_3166-2
Any chance to include 3166-2 support to access, for example, the 50 US states?
Hi, it would be nice to have some "Language <-> Country" mapping.
Optimally both would be a collection, "Language is spoken in this list of countries" and "Country has these languages used" and for each also one main mapping, either separately or by convention as first entry in the returned list. This would be like "if you want to show a flag for this language, then use the flag of country X" and "if you want a default language decision for country x, use this language".
Two new currency codes have been added to ISO-4217 at the start of 2018. Please add support for these currencies ASAP.
MRU 929, Mauritanian Ouguiya (replaces MRO) https://www.currency-iso.org/dam/isocy/downloads/dl_currency_iso_amendment_165.pdf
STN 930, Sao Tome and Principe Dobra (replaces STD) https://www.currency-iso.org/dam/isocy/downloads/dl_currency_iso_amendment_164.pdf
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.