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

Feature/icelandic language support #1116

Conversation

Kristinn-Stefansson
Copy link
Contributor

As a native Icelandic speaker I wanted to contribute support for the language. Converting numeric data to words was my main aspiration so localisations of ToWords and ToOrdinalWords was the core aim, with Dates, TimeSpans, Headings and Bytes then being straightforward enough to add along the way. Icelandic has a few nuances there that some other North Germanic languages have left behind, even though heavier levels of inflection including four cases and noun declension are not in the picture. Still, I hope the submitted implementation is both transparent and in line with the established code. I have run a copy of the build process to validate that all tests pass on the PR, and did some benchmarks on the side to try and make sure the performance compared favorably with a selection of other language implementations.

The PR checklist:

  • Implementation is clean
  • Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • No Code Analysis warnings
  • There is proper unit test coverage
  • If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • Xml documentation is added/updated for the addition/change
  • Your PR is (re)based on top of the latest commits from the dev branch (more info below)
  • Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • Readme is updated if you change an existing feature or add a new one
  • Run either build.cmd or build.ps1 and ensure there are no test failures

Make basic tests for accessing resources pass.
Overload DefaultFormatter in IcelandicFormatter, having to trim
plural endings that do not apply to Icelandic while anticipating
gender rules for Icelandic localisation of time based units with month
and day being masculine, year being neuter and others, eg. seconds
and hours taking the feminine gender. This called for access to
CultureInfo as base class does not expose this (improvement
suggestion?).
Register the Icelandic Formatter in Formatter Registry.
Some code branches cannot be unit tested in formatter as e.g.
Argument Exception can only be thrown if missing resource key.
Dual and TrialQuadral resource strings not included as they do not
apply to the Icelandic implementation.
Consisted of adding "og" to registry.
Similar tests as applied to e.g. German made to pass for Icelandic.
Using Tölvuorðasafn and Íðorðasafn as base for using kB for
kilobtytes and b as symbol for bit.
Relied on already translated resources and similar tests for other
languages of Germanic origin.
Included TimeOnly as usage in .NET 6.0 is approaching.
Icelandic has some complexity that can be attributed to being 'closer'
to its root than other surviving Germanic languages and having both
more irregularities and retaining inflections such as four case
synthetic grammar. This can mostly be represented with code
branching specific to this implementation. Among other thing the
first four natural numbers change based on gender and gender must
be applied to the last number in a sequence. Rules are mostly consistent for powers of ten, but 'hundred' varies between single and
plural. After performance measurements the final version was chosen
to closely align with other implementations, while trying to be as
transparent as possible.
The Icelandic rules for ordinals are have additional requirements, e.g.
on whether the penultimate number group or only the last match the
rule.
BenchmarkDotnet used on a parallel branch to make sure the
implementation compares favarobly to other localisations.
Code analysis run and no issues found in Icelandic language
support files.
Fix one mission EOL warning in PR view.
Restore AND handling code previously suggested by
code coverage to be superfluous, but that turned
out to be needed.
Added test and fix for the somewhat edge case of
"the one million and two thousandth" ordinal in Icelandic
Copy link
Member

@clairernovotny clairernovotny left a comment

Choose a reason for hiding this comment

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

This looks great, thank you! I noticed a few things in the ResX that did not appear to be translated; are those accurate?

src/Humanizer/Properties/Resources.is.resx Outdated Show resolved Hide resolved
src/Humanizer/Properties/Resources.is.resx Outdated Show resolved Hide resolved
src/Humanizer/Properties/Resources.is.resx Outdated Show resolved Hide resolved
Missing in _Above20 for seconds, days and years.
Forgot to add tests again after debugging
@clairernovotny
Copy link
Member

The one remaining piece is to add a reference to this language in the main metapackage, like this:
https://github.com/Humanizr/Humanizer/blob/main/NuSpecs/Humanizer.nuspec#L36

Once that's done, I can merge this and get a release out.

@clairernovotny clairernovotny merged commit aa107c6 into Humanizr:main Aug 22, 2021
@Kristinn-Stefansson Kristinn-Stefansson deleted the feature/IcelandicLanguageSupport branch September 12, 2021 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants