Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

Chouby on "[Plugin: Polylang] [Request] Back-end flag for greenlandic (kl_KA)"

$
0
0

Hi!

To create the list of builtin languages, I initially looked at the WP 3.1 translations (first version supported by Polylang). Now I add languages supported in WP languages packs or contributed Polylang translations.

However here is how to solve your problem.

Create a directory wp-content/polylang, add your flag file in this directory and name it kl_KA.png since you chose kl_KA as locale for your language. Polylang will use this flag on frontend.

It won't use it on backend because people may use big custom flags and there is a risk to get an ugly result on backend side.

So you will need to put some php code to achieve your goal:
Create a file wp-content/polylang/pll-config.php and put this in it:

<?php
add_filter('pll_get_flag', 'pll_get_flag', 10, 2);
function pll_get_flag($html, $slug) {
	global $polylang;

	if ('kl' == $slug) {
		$lang = $polylang->get_language($slug);

		if (file_exists(PLL_LOCAL_DIR.($file = '/'.$lang->locale.'.png')) || file_exists(PLL_LOCAL_DIR.($file = '/'.$lang->locale.'.jpg')) )
			$url = PLL_LOCAL_URL.$file;

		$html =	sprintf(
			'<img src="%s" title="%s" alt="%s" />',
			$url,
			esc_attr(apply_filters('pll_flag_title', $lang->name, $lang->slug, $lang->locale)),
			esc_attr($lang->name)
		);
	}
	return $html;
}

Edit: you need Polylang 1.6


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>