Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added i18n support #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"require": {
"php": ">=5.4.0",
"tinymce/tinymce": "^4.5.6",
"tweeb/tinymce-i18n": "^1.8.0",
"yiisoft/yii": "~1.1.18"
},
"autoload": {
Expand Down
14 changes: 14 additions & 0 deletions src/TinyMceWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ class TinyMceWidget extends CInputWidget {
*/
public $fileManager = false;

/**
* @var bool Whether widget should be localized using `Yii::app()->lang`.
*/
public $localized = true;

/**
* Default widget configuration.
*
Expand Down Expand Up @@ -119,13 +124,22 @@ class TinyMceWidget extends CInputWidget {
*/
private $tinymceAssetsDir;

/**
* @var string
*/
private $tinymceLangsDir;

/**
* {@inheritdoc}
*
* @throws CException
*/
public function init() {
$this->tinymceAssetsDir = Yii::app()->assetManager->publish(Yii::getPathOfAlias('vendor.tinymce.tinymce'));
if($this->localized) {
$this->tinymceLangsDir = Yii::app()->assetManager->publish(Yii::getPathOfAlias('vendor.tweeb.tinymce-i18n.langs'));
$this->defaultSettings['language_url'] = $this->tinymceLangsDir . '/' . Yii::app()->language . '.js';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should ensure that this file exist before we try to load it. It may also require some normalization, since there may be different conventions for languge code (pt vs pt_pt vs pt_PT).

}

$this->settings = CMap::mergeArray($this->defaultSettings, $this->settings);
}
Expand Down