All Downloads are FREE. Search and download functionalities are using the official Maven repository.

pl.allegro.finance.tradukisto.internal.languages.latvian.LatvianPluralForms Maven / Gradle / Ivy

Go to download

Small java library created to convert numbers to their word representations

The newest version!
package pl.allegro.finance.tradukisto.internal.languages.latvian;

import pl.allegro.finance.tradukisto.internal.languages.GenderType;
import pl.allegro.finance.tradukisto.internal.languages.PluralForms;

public class LatvianPluralForms implements PluralForms {

    private final String singularForm;
    private final String pluralForm;

    private final GenderType genderType;

    LatvianPluralForms(String singularForm, String pluralForm, GenderType genderType) {
        this.singularForm = singularForm;
        this.pluralForm = pluralForm;
        this.genderType = genderType;
    }

    @Override
    public String formFor(Integer value) {
        if (useSingular(value)) {
            return singularForm;
        } else {
            return pluralForm;
        }
    }

    private boolean useSingular(Integer value) {
        return value == 1 || (value % 100 != 11 && value % 10 == 1);
    }


    @Override
    public GenderType genderType() {
        return genderType;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy