RubenSardinha
RubenSardinha

Reputation: 19

Symfony2 Intl Language

I have to know what are the codes(ISO codes) of the languages in

Intl::getLanguageBundle()->getLanguageNames($this->name);

Anyone know how to do that?

Update

I discover that the codes are in

"alpha-2 code" and exist a list in the site http://www.nationsonline.org/oneworld/language_code.htm

but I what to see the list of the Intl::getLanguageBundle() to see if it has any different codes

Thanks in advance for any help

Upvotes: 1

Views: 122

Answers (1)

giosh94mhz
giosh94mhz

Reputation: 3086

From the LanguageBundleInterface class, here's the relevant docblock:

/**
 * Returns the names of all known languages.
 *
 * @param string $displayLocale Optional. The locale to return the names in.
 *                              Defaults to {@link \Locale::getDefault()}.
 *
 * @return string[] A list of language names indexed by language codes.
 */
public function getLanguageNames($displayLocale = null);

So you just need to use the result like this:

$languages = Intl::getLanguageBundle()->getLanguageNames($this->name);
foreach ($languages as $code => $name) {
    /*...*/
}

Upvotes: 2

Related Questions