Support customized language
Lhfcws opened this issue · 3 comments
I'm using jfairy 0.5.6.
I want to add a chinese config jfairy_zh.yml
and create Fairy by Fairy.create(Locale.CHINA)
.
In most situations it is ok to use default EnFairyModule as English is most popular language in the world.
However I met with an Exception
java.lang.IllegalArgumentException: No enum constant io.codearte.jfairy.producer.util.LanguageCode.ZH
at java.lang.Enum.valueOf(Enum.java:236)
at io.codearte.jfairy.producer.util.LanguageCode.valueOf(LanguageCode.java:7)
at io.codearte.jfairy.Bootstrap.getFairyModuleForLocale(Bootstrap.java:118)
I believe that return a default value (LanguageCode.EN) of LanguageCode.valueOf() (or a wrapper method) for unknown locale may be more reasonable, as there is a coming switch-default structure to handle the unknown locale.
LanguageCode code = null;
try {
code = LanguageCode.valueOf(locale.getLanguage().toUpperCase());
} catch (IllegalArgumentException e) {
LOG.warn("Uknown locale " + locale);
code = LanguageCode.EN;
}
==========
Another question is that ./gradlew build
always fails with exceptions signing.keyId and signing.secretKeyRingFile has to be configured
while building the project cloning from github. I'm not familiar with gradle :( (I use maven).
If you guys intend to support Chinese language , I would like to help. Thanks.
Hello @Lhfcws , thank you for your interest in our project. In order to add a new locale to jFairy, some more changes are needed, including adding a new code to LanguageCode.java
and adding new data providers and a FairyModule
class for your languge. If you are interested in doing that, you can use this @andidev Pull Request as an example: https://github.com/Codearte/jfairy/pull/60 . Alternatively, you can just provide the content yamls and submit to us so that we can do the rest, but this will definitely take some time. Gradle does not build correctly cause it expects you to provide a gpg key id and keyring. In order to make it work, you will have to generate such a key and then put add the required values to a gradle.properties
file placed in the user gradle home, by default set to user_home/.gradle in linux. You can find more information on the gradle environment here: https://docs.gradle.org/current/userguide/build_environment.html.
Thanks for the replies. ./gradlew build -x sign
did work.
@OlgaMaciaszek I'll try to go through the project and make sure that my yaml config satisfies all features. It seems that it is not so simple as just providing a yaml config file. For example, the company url will become chinese if I just modify the given faked company names into Chinese.
If I have to guarantee that my yaml config works fine, posting a PR including tests by me is a better way to solve the Chinese support issue.