Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Localize countries in PrimeFaces Extensions pe:inputPhone dropdown

Is there any way to change the used language in the above mentioned component dropdown?

adding lang="DE" for german language did not work:

    <div class="p-field p-col-12 p-md-6">
                    <h7>Festnetz</h7>
                    <pe:inputPhone id="festnetz" label="Hallo" lang="DE"
                        initialCountry="#{kontakt.countryIsoFestnetz}"
                        value="#{kontakt.festnetz}" formatOnDisplay="true">
                        <p:ajax event="countrySelect"
                            listener="#{kontakt.onCountrySelectFestnetz}" />
                    </pe:inputPhone>
                </div>
like image 547
Jürgen Hochköppler Avatar asked Dec 22 '25 21:12

Jürgen Hochköppler


1 Answers

PrimeFaces Extensions 12.0.2 and up

Since PrimeFaces Extensions 12.0.2 you can use the localizedCountries to do so. You can either supply a Map<String, String> containing the ISO 2 abbreviation (lower case) (key), and the name (value):

private Map<String, String> localizedCountries;

@PostConstruct
protected void init() {
    localizedCountries = new HashMap<>();
    localizedCountries.put("nl", "Nederland");
    localizedCountries.put("be", "België");
    localizedCountries.put("de", "Duitsland");
}

// Add getter
<pe:inputPhone onlyCountries="nl,be,de"
               localizedCountries="#{bean.localizedCountries}"/>

or a JSON string:

<pe:inputPhone onlyCountries="nl,be,de"
               localizedCountries="{'nl':'Nederland','be':'België','de':'Duitsland'}"/>

See also:

  • https://github.com/primefaces-extensions/primefaces-extensions/issues/983
like image 58
Jasper de Vries Avatar answered Dec 24 '25 09:12

Jasper de Vries



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!