Skip to content
This repository has been archived by the owner on Jun 29, 2018. It is now read-only.
/ wp-current-locale Public archive

Library/helper for determining the current locale ('language') selected (different multilingual plugins)

License

Notifications You must be signed in to change notification settings

strarsis/wp-current-locale

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wp-current-language

Library/helper for determining the current language selected (different multilingual plugins)

Deprecated

This repository has been deprecated because it is sufficient to use get_locale() for retrieving the current locale across different language plugins.

Note:

There is a confusion over 'Language' and 'Locale'. A 'Locale', in some plugins also called '(Language) Code', is more precise and standardized (e.g. 'en_US', 'en_GB' or 'fr_FR', 'fr_CA') while 'Language' is usually expected to be just the primary language part of the Locale or even the full name of language derived from the Locale ('en' or 'fr' - 'English', 'French' described in some plugins - for the previously given examples).

Whether all these plugins properly return the locale in the same format has to be determined yet (see TODO below).

Should this explanation itself be too inaccurate or you think can be further improved, feel free to create an issue so this can be fixed!

Helper usage:

get_current_locale()

List of multilingual plugins and functions for current language

Supports the WPML style ICL_LANGUAGE_CODE constant and additionally exposes its own function pll_current_language(name, locale or slug).

Stores the current locale in ICL_LANGUAGE_CODE.

Recent versions:

qtranxf_getLanguage()

Older versions (qtranslate without the 'x'?):

qtrans_getLanguage() Compatibility code in recent version

bbl_get_current_lang()->code

(Relevant issue: https://github.com/inpsyde/MultilingualPress/issues/263)

Current release

(global namespace): mlp_get_current_blog_language($short = FALSE)

Newer release

(Inpsyde\MultilingualPress namespace): Inpsyde\MultilingualPress\get_current_site_language($language_only)

transposh_get_current_language()

xili_curlang()

the_curlang() (soon obsolete according to source comment)

Seems to use Polylang.

Plugin not listed here?

Please create an issue and tell me!

TODO:

  • Returned locale normalization (if required).