OneThird CMS

Lightweight CMS for Small website, Web application framework.

Download Document

japanese

For multi-language support

The gist of this page

  1. In OneThird CMS, ways are preparing a multi-language support plug-ins, it recommended to use the page in the meta data (described in this page)
  2. In the method of using the metadata, it can be easily multilingual simply by adding the language name (en, etc.) in the URL
  3. Either way, the link of each Pejihe is adjusted automatically


In OneThird CMS, it offers two of multilingual way


Multilingual plug-in

One way is to use a multi-language support plug-ins

Multilingual plug-ins, but had been shipped as a standard plug-in to v1.2x, since v1.3x, became the extension plug-in

Multilingual plug-in is compatible with unlimited number of languages


To use, please add the following code snippet to /files/1/plugin/plugin.php

	$params['prefix_list'] = array('en');		// ex. array('en','jp',...)
	$plugin_ar[ LANG_PAGE_ID ] = array(
		  'selector' => "multi_language"
		, 'title' => "multi language page"
		, 'add_page' => true
		, 'php' => "multi_language"
	);

	$plugin_ar[ LANG_DATA_ID ] = array(
		  'selector' => "multi_language"
		, 'php' => "multi_language"
		, 'static' => array("p{page}.html","en/p{page}.html")
	);
	
   


download : multi_language.zip


To use, please change the page type of page you want to multi-lingual to the 185 number from the usual No. 1


However, in multilingual it takes a large amount of translation costs, usually English page and the Japanese page to language in a production base

It has become a most 3 language about

Therefore, we recommend another way more simple


How to use the meta-data

Another way is to save the translation information in the meta data in the page

You can easily change the multi-language page by adding the following code snippet to /files/1/plugin/plugin.php


$params['prefix_list'] = array('en');		// ex. array('en','jp',...)
$params['hook']['after_read_page'][] = 'after_read_page_multi_language';
function after_read_page_multi_language(&$page_ar) {
	global $html,$params,$ut;
	$lang = trim($params['url_prefix'],' /');
	$edit_mode = isset($_GET['mode']) && $_GET['mode'] == 'edit';
	$k = array_search($lang,$params['prefix_list']);
	if ($k !== false) {
		if (isset($page_ar['meta']['lang'][$lang]['contents'])) {
			$page_ar['contents'] = $page_ar['meta']['lang'][$lang]['contents'];
		} else {
			if (!$edit_mode) {
				$page_ar['contents'] = "<p style='color:red'>This page has not been translated yet.</p>".$page_ar['contents'];
			}
		}
		if (isset($page_ar['meta']['lang'][$lang]['title'])) {
			$page_ar['title'] = $page_ar['meta']['lang'][$lang]['title'];
		}
		$params['hook']['before_modified'][] = 'before_modified_page_multi_language';
	} else {
		if (check_rights() && isset($page_ar['id'])) {
			$params['add-blockmenu'][] = "<input type='button' value='eng' class='onethird-button mini' onclick='location.href=\"{$ut->link($page_ar['id'],"prefix:en/")}\"' />";
		}
	}
}
function before_modified_page_multi_language(&$new_ar) {
	global $params,$ut;
	if (isset($_POST['draft'])) {
		return true;
	}
	$lang = trim($params['url_prefix'],' /');

	$new_ar['meta']['lang'][$lang]['contents'] = $new_ar['contents'];
	unset($new_ar['contents']);

	$new_ar['meta']['lang'][$lang]['title'] = $new_ar['title'];
	unset($new_ar['title']);

	$new_ar['metadata'] = serialize64($new_ar['meta']);
	unset($new_ar['meta']);
	if (mod_data_items($new_ar)) {
		if (isset($params['top_page'])) {
			header("Location: {$ut->link()}");
			
		} else {
			if ($new_ar['block_type'] == 5) {
				header("Location: {$ut->link($new_ar['link'])}");
			} else {
				header("Location: {$ut->link($new_ar['id'])}");
			}
		}
		exit();
	}
	exit_proc(400, 'Save-Error');
}
   


To use it, a list of languages ​​that you want to support, $params described the prefix in [ 'prefix_list'], please visit, including the prefix described in $params [ 'prefix_list'] in the URL

If there is a translation, if the translation does not appear, you will see the warning statements and Japanese page of that there is no translation

When you edit, you can edit the data for that language

The multilingual plug-in, but you will need to change all the page type that you want to support, can be written in English and is this way only the pages you want to add an English translation


However, in this way, because you are using a page in the meta data, or if extremely large amount of text, you will not be able to correspond to the multi-national language of an amount that does not fit in the meta-information

In addition, there is also a disadvantage not be applied to the search in the normal page search because it uses the metadata


But, then I think that there is no problem as long as the normal sentence amount of about Sanke language will not be a problem if you do not want to use the site search

(If the site in the search is necessary, you can use the page in the search plug-in that the meta-data to the target)


For links automatically adjusted to each link

In OneThird CMS, it has become a rule set forth in all the internal link tag ($link tag or $ut->link tag)

$link tag or, if using a $ ut-> link, link of each Pejihe from the English page is automatically adjusted


Example:

If it is linked to http://test.com/sample2.html in http://test.com/sample1.html


If you open a http://test.com/en/sample1.html

http://test.com/sample2.html is rewritten automatically to http://test.com/en/sample2.html


The method, without having to create individual translated pages as multi-language plug-in can be done at once

But when the translation, it is necessary to perform the individual translation, it is very troublesome

Therefore, it is possible to translate without spending more easily effort captures the Google translation feature

It is the way that has been adopted at this site

Learn More



For canonical

In OneThird CMS, automatically makes the canonical set if it is accessed by other than the original page URL as SEO measures

However, it is whether the subtleties put a canonical English page or the corresponding English page put a canonical of the original page and thought Japanese page

If OneThird not do anything in CMS, URL of the English page will set the canonical Japanese page

Please add the following such code if you do not want to do this

$params['hook']['before_expand'][] = "multi_language_canonical";
	function multi_language_canonical() {
		global $params,$ut;
		if ($params['url_prefix'] == 'en') {
			$params['canonical'] = $ut->link($params['page']['id'],'prefix:en');
		}
	}   





Google Website Translator - Google Translate