Overview

Classes

  • CMLLanguage
  • CMLPost
  • CMLTranslations
  • CMLUtils

Functions

  • cml_dropdown_langs
  • cml_get_browser_lang
  • cml_get_menu
  • cml_get_notice
  • cml_get_the_link
  • cml_is_homepage
  • cml_show_flags
  • Overview
  • Class
  • Tree

Class CMLTranslations

This class is used to get and store custom translations in CECEPPA_ML_TRANSLATIONS table.

Located at api.php
Methods summary
public static
# add( string $key, string $default, string $group, mixed $no_default = false )

This function can be used by 3rd part plugin/theme to allow translation of its strings. Added string can be translated in "My Languages" page.

This function can be used by 3rd part plugin/theme to allow translation of its strings. Added string can be translated in "My Languages" page.

Parameters

$key
string
$key used to store/get your own value from database. To avoid duplicated key use your own prefix for your key. Example: "_yoast_rssafter"
$default
string
$default default value to use
$group
string
$group The group name of your own strings, this name will be displayed in "My Translations" page in "Group" column. Group name should be preceded by "_" symbol.
Example: "_YOAST"
$no_default

Example

Full example is provided here:
http://www.alessandrosenese.eu/en/ceceppa-multilingua/extend-plugin-theme-compatibility/
public static string
# set( int/string $lang, string $original, string $translated, string $type )

Store custom translation in database.

Store custom translation in database.

Since 1.4 CML generate GNUTEXT mo file from stored translations. The domain used to generate translation is: "cmltrans".

Mo file isn't generated automatically, but you have to call manually the function cml_generate_mo_from_translations()

This function will return the id of inserted record.

Parameters

$lang
int/string
$lang - id/slug of language
$original
string
$original - original string
$translated
string
$translation - translated string
$type
string
$type - type of translation( W: Widget, S: Custom strings ). Type field is used "internally" to show records in correct table, like Widget titles, My translations...

Returns

string

Example

<?php _e( "Hello", "cmltrans" ); ?> Use "get" function instead of __, _e, because if "mo" generation fails, this function will get translation from database
public static string
# get( int/string $lang, string $string, string $type = "", boolean $return_empty = false, boolean $ignore_po = false )

return translation stored in cml_trans table by key

return translation stored in cml_trans table by key

This function will get translation from ".mo" file if: 1) it's generated correctly 2) $lang == current language

otherwise will get translation from database

<strong>string match is case sensitive</strong>

Parameters

$lang
int/string
$lang - language id or slug
$string
string
$string - string to translate
$type
string
$type - ( optional ) This is used internally by Ceceppa Multilingua, only in admin interface T - Site Title/Tagline, W - Widget, M - My translations
$return_empty
boolean
$return_empty - If true, return empty string if no translation is found
$ignore_po
boolean
$ignore_po Since 1.4 the plugin will generate mo file for all translation stored in CECEPPA_ML_TRANSLATIONS ( widget titles, my translations, site title/tagline... ). So by default if $lang == current language, the plugin will get translation from ".mo" file instead query the database. You can force to retive translation from database.

Returns

string
public static
# search( string $lang, string $text, mixed $group )

return key stored in translations table by its translation

return key stored in translations table by its translation

Parameters

$lang
string
$text to search
$text
string
$group group
$group
public static
# delete_text( mixed $text, mixed $group )
API documentation generated by ApiGen 2.8.0