Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • None
  • system
    • base
    • caching
    • console
    • db
      • ar
      • schema
    • validators
    • web
      • actions
      • auth
      • helpers
      • widgets
        • captcha
        • pagers
  • zii
    • widgets
      • grid

Classes

  • AccountsGridViewProfileWidget
  • ActionMenu
  • ActionsGridViewProfileWidget
  • ActionsQuickCreateRelationshipBehavior
  • ActiveDateRangeInput
  • ApplicationConfigBehavior
  • Attachments
  • ChatBox
  • CommonControllerBehavior
  • ContactMapInlineTags
  • ContactsGridViewProfileWidget
  • CronForm
  • CSaveRelationsBehavior
  • DateRangeInputsWidget
  • DocsGridViewProfileWidget
  • DocViewer
  • DocViewerProfileWidget
  • EButtonColumnWithClearFilters
  • EmailDeliveryBehavior
  • EmailProgressControl
  • EncryptedFieldsBehavior
  • EventsChartProfileWidget
  • FileUploader
  • FontPickerInput
  • Formatter
  • FormView
  • GridViewWidget
  • History
  • IframeWidget
  • ImportExportBehavior
  • InlineActionForm
  • InlineEmailAction
  • InlineEmailForm
  • InlineEmailModelBehavior
  • InlineQuotes
  • JSONEmbeddedModelFieldsBehavior
  • JSONFieldsDefaultValuesBehavior
  • LeadRoutingBehavior
  • LeftWidget
  • LoginThemeHelper
  • LoginThemeHelperBase
  • MarketingGridViewProfileWidget
  • MediaBox
  • MessageBox
  • MobileFormatter
  • MobileFormLayoutRenderer
  • MobileLayoutRenderer
  • MobileLoginThemeHelper
  • MobileViewLayoutRenderer
  • ModelFileUploader
  • NewWebLeadsGridViewProfileWidget
  • NormalizedJSONFieldsBehavior
  • NoteBox
  • OnlineUsers
  • OpportunitiesGridViewProfileWidget
  • Panel
  • ProfileDashboardManager
  • ProfileGridViewWidget
  • ProfileLayoutEditor
  • ProfilesGridViewProfileWidget
  • Publisher
  • PublisherActionTab
  • PublisherCalendarEventTab
  • PublisherCallTab
  • PublisherCommentTab
  • PublisherEventTab
  • PublisherSmallCalendarEventTab
  • PublisherTab
  • PublisherTimeTab
  • QuickContact
  • QuickCreateRelationshipBehavior
  • QuotesGridViewProfileWidget
  • RecordAliasesWidget
  • RecordViewLayoutManager
  • RecordViewWidgetManager
  • RememberPagination
  • Reminders
  • ResponseBehavior
  • ResponsiveHtml
  • SearchIndexBehavior
  • ServicesGridViewProfileWidget
  • SmallCalendar
  • SmartActiveDataProvider
  • SmartDataProviderBehavior
  • SmartSort
  • SocialForm
  • SortableWidgetManager
  • SortableWidgets
  • TagBehavior
  • TagCloud
  • TemplatesGridViewProfileWidget
  • TimeZone
  • TopContacts
  • TopSites
  • TransformedFieldStorageBehavior
  • TranslationLogger
  • TwitterFeed
  • TwoColumnSortableWidgetManager
  • UpdaterBehavior
  • UpdatesForm
  • UserIdentity
  • UsersChartProfileWidget
  • WorkflowBehavior
  • X2ActiveGridView
  • X2ActiveGridViewForSortableWidgets
  • X2AssetManager
  • X2AuthManager
  • X2ChangeLogBehavior
  • X2ClientScript
  • X2Color
  • X2DateUtil
  • X2FixtureManager
  • X2FlowFormatter
  • X2GridView
  • X2GridViewBase
  • X2GridViewForSortableWidgets
  • X2GridViewSortableWidgetsBehavior
  • X2LeadsGridViewProfileWidget
  • X2LinkableBehavior
  • X2ListView
  • X2PillBox
  • X2ProgressBar
  • X2SmartSearchModelBehavior
  • X2TimestampBehavior
  • X2TranslationBehavior
  • X2UrlRule
  • X2WebModule
  • X2Widget
  • X2WidgetList
  • Overview
  • Package
  • Class
  • Tree

Class X2TranslationBehavior

A behavior to automatically parse the software for translation calls on text, add that text to our translation files, consolidate duplicate entries into common.php, and then translate all missing entries via Google Translate API. To run the translation automation, navigate to "admin/automateTranslation" in the software. End users should never need to run this code (and in fact without the Google API Key file and Google Translation Billing API configured it will not work). This class is primarily designed for developer use to update translations for new releases.

CComponent
Extended by CBehavior implements IBehavior
Extended by X2TranslationBehavior
Package: application\components
Author: "Jake Houser" <jake@x2engine.com>, "Demitri Morgan" <demitri@x2engine.com>
Located at x2engine/protected/components/X2TranslationBehavior.php
Methods summary
public string
# getRegex( string $allowedChars = "(){}_.-,+^%@*#|&!?/<>;:" )

The regular expression for matching calls to Yii::t

The regular expression for matching calls to Yii::t

See protected/tests/data/messageparser/modules1.php for examples of what will be matched by this pattern.

Parameters

$allowedChars
string
$allowedChars valid special characters to match inside of translation calls

Returns

string
the constructed regex pattern
public
# addMissingTranslations( )

Add missing translations to files, first step of automation.

Add missing translations to files, first step of automation.

Function to find all untralsated text in the software, and then take that array of messages and add them to translation files for all languages. Called in X2TranslationAction::run function as part of the full translation suite.

public
# getAttributeLabels( )
public string|boolean
# getTranslationFileName( string $modelName )

Converts model name to translation file name.

Converts model name to translation file name.

Helper method called in X2TranslationBehavior::getMessageList() to find the correct translation file for a model. This is necessary because some models have class names like Quote or Opportunity but their file names are quotes and opportunities.

Parameters

$modelName
string
$modelName The name of the model to look up the related translation file for.

Returns

string|boolean
Returns the name of the translation file to use, or false if a correct file cannot be found.
public array
# fileList( string $revision = null )

Parse file structure for valid files.

Parse file structure for valid files.

Returns a list of all files in the codebase that are eligible for searching for Yii::t calls within.

Parameters

$revision
string
$revision Unused, may implement comparison between Git revisions rather than searching all files.

Returns

array
List of files to be parsed for Yii::t calls
public boolean
# excludePath( string $relPath )

Returns true or false based on whether a path should be parsed for messages.

Returns true or false based on whether a path should be parsed for messages.

Some files in the software don't need to be translated. Yii provides all of its own translations for the framework directory, and there are other files which simply have no possibility of having Yii::t calls in them. Ignoring these files speeds up the process, especially since framework is a very large directory.

Parameters

$relPath
string
$relPath Paths to folders which should not be included in the Yii::t search

Returns

boolean
True if file should be excluded from the search, false if the file is OK.
public array
# getMessageList( mixed $file )

Gets a list of Yii::t calls.

Gets a list of Yii::t calls.

Helper function called by X2TranslationBehavior::addMissingTranslations() to get a list of messages found in Yii::t calls found in the software in an easily parsed array format. Also checks attribute labels of non-custom modules in the x2_fields table.

Returns

array
An array of messages found in the software that need to be added to the translation files.
public array
# parseFile( string $path )

Return Yii::t calls in a specific file

Return Yii::t calls in a specific file

Helper method called in X2TranslationBehavior::getMessageList() Parses a file and returns an associative array of module names to messages for that file.

Parameters

$path
string
$path Filepath to the file to be checked by the REGEX

Returns

array
An array of messages in Yii::t calls in the provided file.
public
# parseRegexMatch( mixed $message )
public
# addMessages( type $file, type $messageList, mixed $common = null )

Commented out until unit test is built.

Commented out until unit test is built.

Parameters

$file
type
$file
$messageList
type
$messageList
$common
public
# consolidateMessages( )

Move commonly used phrases to common.php, second step of automation.

Move commonly used phrases to common.php, second step of automation.

Function that parses translation files for all languages and consolidates them. First it builds a list of redundancies between files, then loops through that array, adding redundant phrases to common.php and removing them from their original files. This means any given word/phrase in the software only needs to be translated once. Called in X2TranslationAction::run function as part of the full translation suite.

public
# buildRedundancyList( )

Get redundant translations to be merged into common.php

Get redundant translations to be merged into common.php

Helper function called by {@link consolidateMessages) to build a list of files that have redundant messages in them, as well as a list of what those messages are. Loads this data into the property $this->intersect;

public
# addToCommon( string $message )

Add a message to common.php for all languages

Add a message to common.php for all languages

Helper function called by X2TranslationBehavior::consolidateMessages() to add a redundant message into common.php. The message will nto be added if it already exists in common.

Parameters

$message
string
$message The message to be added to common.php
public
# removeMessage( string $file, string $message )

Deletes a message from a language file in all languages.

Deletes a message from a language file in all languages.

Called as a part of the consolidation process to remove redundant messages from the files they were found in. This keeps the amount of messages lower and reduced the burden on anyone who is translating the software.

Parameters

$file
string
$file The name of the file to look for the message in
$message
string
$message The message to be removed
public
# updateTranslations( )

Call Google Translate API for mising translations, third step of automation.

Call Google Translate API for mising translations, third step of automation.

This method will get a list of all messages which do not have translations into the appropriate language from all of our language files. Then, it will call Google Translate's API to get a base translation of the message and insert the translated versions into our translation files. Called in X2TranslationAction::run function as part of the full translation suite.

public array
# getUntranslatedText( )

Get all untranslated messages

Get all untranslated messages

Helper function called by X2TranslationBehavior::updateTranslations() to get an array of all messages which have indeces in the translation files but no translated version.

Returns

array
A list of all messages which have missing translations.
public string
# translateMessage( string $message, string $lang )

Translate a message via Google Translate API.

Translate a message via Google Translate API.

Helper function called by X2TranslationBehavior::updateTranslations() to translate individual messages via the Google Translate API. Any text between braces {} is preserved as is for variable replacement.

Parameters

$message
string
$message The untranslated message
$lang
string
$lang The language to translate to

Returns

string
The translated message
public
# addNoTranslateTags( mixed $message )
public
# removeNoTranslateTags( mixed $message )
public
# replaceTranslations( string $lang, string $file, array $translations )

Add translated messages to translation files.

Add translated messages to translation files.

Helper function called by X2TranslationBehavior::updateTranslations() to replace the untranslated messages in a translation file with the response we got from Google.

Parameters

$lang
string
$lang The language we translated our messages to
$file
string
$file The file we need to put the translations in
$translations
array
$translations An array of translations with the English message as the index and the translated version as the value.
public
# mergeCustomTranslations( )
public
# mergeCustomLanguagePack( mixed $dir )
public
# mergeCustomTranslationFile( mixed $file )
public
# assimilateLanguageFiles( )
public
# assimilateLanguagePack( mixed $lang )
public
# assimilateLanguageFile( mixed $lang, mixed $file )
Methods inherited from CBehavior
attach(), detach(), events(), getEnabled(), getOwner(), setEnabled()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public boolean $verbose false
#
public integer $newMessages 0
#
public integer $addedToCommon 0
#
public integer $messagesRemoved 0
#
public integer $untranslated 0
#
public integer $characterCount 0
#
public integer $customMessageCount 0
#
public array $languageStats array()
#
public array $errors array()
#
public boolean $limitReached false
#
Magic properties inherited from CBehavior
$enabled, $owner
X2CRM Documentation API documentation generated by ApiGen 2.8.0