(tested with PHP8 & Typesetter 5.3)
Multilang plugin together with custom core texts and custom plugins texts translation.
Google Translation Assistant
Huge flag collection for languages.
Language selected GADGET for public pages (with a lot of admin changed layout options).
Admin language (public pages language and administration language can be changed separately).
And much more ...
Should be working with Typesetter 5.0.3 and Typesetter 5.1.0 (tested in Chrome and Firefox).
This plugin does not have any deeper help texts yet but it is very intuitive, I believe.
Two language, english and estonian included.
Plugin with flags is up to 4mb (zipped)
Plugin is multi-language. You can translate plugin texts if "Rif Multilanguage Manager" is installed.
English need correction. If you change language files or add some new, please send a link to the files (Contact)
Select languages what you need for use.
Language list is now sortable and is displayed in codes, flags etc..
Allows selecting the language for public pages and for admin texts separately.
540 languages with flags 25x15, named by language code.
280 additional bigger flag images named by "Country Name" and sorted by its sizes in folders (sizes: 16x16, 24x24, 32x32, 48x48, 64x64, 128x128)
Public pages' language stored in session to remember the language.
Adminlang stored in user file for remembering it
PS! The Gadget has admin links if mouse hower on it (close box, if you want to select the language).
Custom translation allows translating Core texts, and Plugin texts to any language that you've selected for use for your pages.
There are also some searching options.
All Core language texts are the admin texts. You can filter them to use like public page texts (there are prefiltered texts for contact form, login-box and more).
If Plugin has a page Text.php file, then its texts are also translatable.
If Plugin is rif-multilang plugin ready and has admin texts translation files inside it, these texts are also translatable.
If Plugin does not have any traslating texts, then we have only these translation options:
PS! Core inline page texts change popup dialog is replaced with rif-multilang plugin dialog to save multi lang texts.
MENU MANAGER:
Multiple Special pages on the menus have their own Slug and Title and new addToURL parameters (Rename/Details dialog).
NB! I made it for Simple Blog addon. This allow-add multiple category links to the menu. This is experimental. Maybe it works some other addon too (working only if addToURL fileld is not empty).
Dialog for adding a new page to the menu has now a new tab for special page select.
Add Translation link added and shows the flags (on click translation dialog opened)
Different colors for External links and Special pages.
Translation page visibility and remove are syncing by primary language page.
SECTIONS:
Colors and grouping in File Include dialog.
Aditional parameters in File Include dialog for selecting sections that we want to include. I made it for galleries. When we edit gallery images in primary language page then we do not need to edit lang page. You can include default language page to other lang page and select gallery section only to include.
NB! If you install this plugin and want to use this feature, you must over save regular pages to put unique id for sections (include sections and wrapper sections do not have the unique id and do not allow to select!!).
There is also additional parameter field for special include. This is not working yet (future work).
If you rename section title to "private" then this section showing on the page for admins only. (Sometimes other admins need some help texts)
If you can, please donate, thaks :-)
If you downloaded or installed this plugin from the Typesetter repository and if you need country flags 64x64 and 128x128 then download it. Unzip and add folders via ftp to rif-Multi_Language flags folder.
Download, copy folder inside zip file to your Typesetter "addon" folder in server via ftp and run install in Plugin Manager.
If the original multilanguage plugin has been installed, then message "uninstall it first!" is shown.
Existing old data must be backed up and used.
Run install again.
Add language select gadget to template - gpOutput::Get('Gadget','Language_Select'); (just like original plugin)
If you want to translate Extracontent? We need to make some changes in the core file.
This is an automated process but if something goes wrong, do it manually.
In function GetExtra( ...
replace line $name = str_replace(' ','_',$name);
to
$name = str_replace(' ', '_', gpPlugin::Filter('ExtraContentFile', array($name)));
PS! This is a new Hook. Now each laguage page own diferent extracontent file (ex. named Contact.-et in estonian page)
NB! After updating gpEasy/Typesetter, then plugin install is automatically refreshed (we need to write some lines back to core script. not strongly tested).
If some important codes have been changed in future versions on core, it might not work. Also if some html code have been changed, some translations might not work).
In the beginning I made two separate plugins. Translation plugin and Multilingual plugin. They have been in use since 2014. At the beginning of 2016, I put these two together. 2017 In September I started to create additional opportunities for him. At the beginning of December 2017, I was so far off to release the beta version for public. I have tested it on my own pages and my client sites (including installation and uninstallation). But we need more tests. It's still a beta version at the moment. It should work on Typesetter versions 4.6, 5.0 and 5.1.
If you do not have a pre-installed Multi-Language plugin created by Josh. Then there should be no danger.
In the latter case, the Joshi plugin translation pages and settings will automatically be migrated. If you have a lot of translation pages, you can make a backup of the Joshi Multi Language data directory from ftp. So later, if you decide to re-place Joshi plugin then you can upload this data directory back to its place. (I did not have problems myself and did not need this move).
Ps! I've detected some bugs, will soon fix them and download a new version. For example, the translation of Core texts does not work if they have already been translated into Typesetter (for example, Contact Form)
rif-Multi Language addon custom translation ready admintexts translation class example.
Translations work olso without rif-multilang installation (if you change languge in typesetter configuration).
Download plugin example ExampleMultilagAddon.zip
////////// WRITE THIS CLASS AND FUNTIONS - make php file and put it to plugin folder (ex. TextAdmin.php):
class YourUniqueClassname_languages{
########## admin texts translation works without rif-multilang plugin ###########
static function Translates($path){
global $config, $langmessage, $addonPathCode, $gpAdmin, $addon_current_id;
#### If you want to use translated admin texts on your visitor pages then close the following two lines
if( common::loggedIn() )
return: $path;
##
if(!isset($langmessage[$addon_current_id])){
$langsdir = $addonPathCode."/languages/";//do not change it
$langmessage[$addon_current_id] = array();
$adminlang = $config["language"];
########## check if adminlang is set (If rif-multilang plugin is installed) ##############
$users = gpFiles::Get('_site/users');
if(!empty($users[$gpAdmin['username']]['adminlang'])){
$adminlang = $users[$gpAdmin['username']]['adminlang'];
}
########## rif-multilang plugin (change adminlang link) ###########
if(isset($_GET['adminlang']))
$adminlang = $_GET['adminlang'];
########## nclude default language file ############
$langmessage[$addon_current_id] = self::PluginLangmessages($langsdir."en.main.inc");
############ overwrite default langfile ###########
if(file_exists($addonPathCode."/languages/".$adminlang.".main.inc")){
$addlangmessages = self::PluginLangmessages($langsdir.$adminlang.".main.inc");
$langmessage[$addon_current_id] = self::ThreeDimArray($addlangmessages, $langmessage[$addon_current_id]);
}
}
return $path;
}
############# plugin langmessage file include #########
static function PluginLangmessages($Path){
global $addon_current_id;
$langmessage = array();
include($Path);
########### Check langmessage pluginid key if exists #########
if(isset($langmessage[$addon_current_id]) && is_array($langmessage[$addon_current_id]))
$langmessage = $langmessage[$addon_current_id];
return $langmessage;
}
static function ThreeDimArray($addlangmessages, $langmessages){
foreach($addlangmessages as $key => $val){
if(!is_array($val))
continue;
if(!isset($langmessages[$key]))
$langmessages[$key] = array();
$addlangmessages[$key] = $addlangmessages[$key]+$langmessages[$key];
foreach($val as $_key => $_val){
if(!is_array($_val))
continue;
if(!isset($langmessages[$key][$_key]))
$langmessages[$key][$_key] = array();
$addlangmessages[$key][$_key] = $addlangmessages[$key][$_key]+$langmessages[$key][$_key];
}
}
return $addlangmessages+$langmessages;
}
then add this lines to your addon.ini file:
[WhichPage]
script = 'TextAdmin.php';
method = 'YourUniqueClassname_languages::Translate';
Store your plugin directory in the folder, ex. languages/en.main.inc (this is default language and must be there), langcode.main.inc, and so one. (Please don't change folder name and language file names must by lancode.main.inc)
This file character encoding must be utf-8 without bom.
Inside language file:
<?php
$langmessage = array(
'Text' => 'TextTextText',
'Your text 2' => 'TextTextText', //etc.
########## NB! addissional adminlinks translation. If multilang plugin installed, we traslate this texts by javascript.
"--ADMIN_LINKS--" => array(
"--Plugin_Name--" => "your plugin label (ini file Addon_Name)",
"--Plugin_About--" => "your plugin About text (ini file About)",
"--MoreInfoLink--" => "http://yoursite.com",
// "Admin_Link:Name_name (you find it on ini file [Admin_Link:Name_name])" => "translate label text",
// "Special_Link:name_name (you find it on ini file [Special_Link:Name_name] )" => "translate label text",
// "Gadget:Name_name (you find it on ini file [Gadget:Name_name] )" => "translate label text",
####### NB! If You have Section content plugin (you maybe want translate its label)
// "SectionType:your_type" => "Your Type Label",
######... add Section types hook to ini file: ######
# // [SectionTypes]
# // script = 'Script.php'
# // method = 'Class::SectionTypes'
#
######... and make function, add type 'label' and traslate it
# // static function SectionTypes($section_types){
# // global $langmessage, $addon_current_id;
#
# // $typelabel = "Default label";
# // if(isset($langmessage[$addon_current_id]["--ADMIN_LINKS--"]['SectionType:your_type'))
# // $typelabel = $langmessage[$addon_current_id]["--ADMIN_LINKS--"]['SectionType:your_type'];
#
# // $section_types['section type'] = array('label' => $typelabel, 'color'=>'default color code is optional');
#
# // return $section_types;
# // }
),
);
your scripts show admin texts:
global $langmessage, $addon_current_id;
echo $langmessage[$addon_current_id][text key];
or make a function like that:
function LangMessages($key){
global $langmessage, $addon_current_id;
if(!isset($langmessage[$addon_current_id][$key]))
return $key;
return $langmessage[$addon_current_id][$key];
}
echo LangMessages("your admin text");
You need Text.php file in your plugin folder
and content like that:
<?php
defined('is_running') or die('Not an entry point...');
$texts = array();
$texts[] = 'your text';
$texts[] = 'your other text and so on';
and add this line to your Addon.ini file:
editable_text = 'Text.php'
your script shows and edits these texts:
gpOutput::SelectText('your text value'); //##### only text display ####
gpOutput::GetAddonText('your text value %s', $html); //#### width translation link ($html replaces some text in translation string eg. $html = common::Link('some page','%s');) ####
PHP:
global $ml_object;
if(isset($ml_object->lang)){
//### without message(), it show variables in message box
$ml_object->lang; //### Primary language code
$ml_object->language; //### Primary language (array) ['language name'], ['language name in english'], ['country name'], ['country code']
message($ml_object->ml_lang); //### Selected language code
message($ml_object->sel_language); //### Selected language array ['language name'], ['language name in english'], ['country name'], ['country code']
message($ml_object->langs); //### All used langs (array) langcode => ['language name'], ['language name in english'], ['country name'], ['country code']
//### Flags directory pathes
$ml_object->flags .'/'.$ml_object->ml_lang.'.png'; //### small flags by language code
$ml_object->flagsCN .'/64/'.$ml_object->language['country name'].'.png'; //### bigger flags by Country Name - sizes 128 64 48 32 24 16 (not all langs have Country name)
//### Other configs
message($ml_object->config); //### all configs
message($ml_object->titles); //###
message($ml_object->lists); //### pages by index => langcode => info
message($ml_object->settings); //### Gadget settings
}
JAVASCRIPT:
//### All used languages
var rifmultilang_languages = {"en":{"language name":"English","language name in english":"English","country name":"United Kingdom(Great Britain)","country code":"co.uk"},"et":{"language name":"Eesti","language name in english":"Estonian","country name":"Estonia","country code":"ee"}};
//### Primary language code
var rifmultilang_defaultlang = 'et';
//### Selected language code
var rifmultilang_selectedlang = 'en';
//### Small flags dir (flags by language code)
var rifmultilang_flags = '/addons/rif-Multi_Language/flags/iso639';
//## Bigger flags dir (flags by country name)
var rifmultilang_flagsCN = '/addons/rif-Multi_Language/flags/CountryName';
PS! If you change your plugin ID and/or name in addon.ini. file, then this is not is the same plugin anymore for rif-multilang plugin.
PS! All available languages to use (now language list is array)
'langs' => array ('et' => array ('language name' => 'Eesti', 'language name in english' => 'Estonian', 'country name' => 'Estonia','country code' => 'ee', 'en' => array( ... etc.)
Not all languages have the country name, code etc.. If you want to change or add some languages, see Languages.php file in plugin dir. Flags stored in flags folder (default flags images is named by langcode and larger country flags by "country name".