Adding custom languages and flags
-
Hello,
I am developing an African languages website and would like to use TranslatePress to do it but I have a few questions:
- Is there a way to find out which 221 languages are covered in your Extra Languages add-on? Or should I say, are any of them African languages?
- To add custom languages, do I need to add the below code and edit it for each additional language? And then re-upload the plugin?
:
*/ add_filter( 'trp_wp_languages', 'trpc_add_custom_somali_language', 10, 2 ); function trpc_add_custom_somali_language( $languages ){ $lang = 'so'; if( array_key_exists( $lang, $languages ) ){ return $languages; } // Somali $languages['so'] = array( 'language' => 'so_SO', 'english_name'=> 'Somali', 'native_name' => '˜اَف صَومالي', 'iso' => array( 'so' ) ); global $TRP_LANGUAGE; if( $TRP_LANGUAGE == 'so_SO' ){ $GLOBALS['text_direction'] = 'rtl'; } return $languages; } add_filter('gettext_with_context', 'trpc_somali_rtl', 10, 4); function trpc_somali_rtl($translated, $text, $context, $domain){ global $TRP_LANGUAGE; if($text == 'ltr' && $context == "text direction" && $TRP_LANGUAGE == 'so_SO'){ $translated = 'rtl'; } return $translated; } add_filter( 'trp_flags_path', 'trpc_flags_path_somali', 10, 2 ); function trpc_flags_path_somali( $original_flags_path, $language_code ){ // only change the folder path for the following languages: $languages_with_custom_flags = array( 'so_SO' ); if ( in_array( $language_code, $languages_with_custom_flags ) ) { return plugin_dir_url( __FILE__ ) . 'flags/' ; }else{ return $original_flags_path; } }Thanks,
Grant
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Adding custom languages and flags’ is closed to new replies.