https://github.com/kwn/kohana-language
Language switching support, ORM multilanguage support
https://github.com/kwn/kohana-language
Last synced: about 2 months ago
JSON representation
Language switching support, ORM multilanguage support
- Host: GitHub
- URL: https://github.com/kwn/kohana-language
- Owner: kwn
- Created: 2013-05-11T14:20:07.000Z (about 12 years ago)
- Default Branch: 3.2/master
- Last Pushed: 2013-05-11T15:33:51.000Z (about 12 years ago)
- Last Synced: 2025-02-12T18:55:27.627Z (4 months ago)
- Language: PHP
- Size: 121 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Kohana language switcher and multilanguage ORM support
======================================================Language switch support
-----------------------Just add some links with href that redirects to:
```
http://yourdomain/language/change/
```\ supports two letters language code like "en", "fr", "pl" etc.
Then add an i18n language set method somewere in your code. Your application top controller's before() method should be a good place to put this code into.
```
i18n::lang(Session::instance()->get('_lang', Language::base()));
```You can set the base language in your config file.
ORM multilanguage support
-------------------------Create your database schema like this:
```
articles:
id
created
updated
author_id
etc...article_langs:
id
article_id
language_id
title
content
etc...
```Extend your article model with ORML:
``` php
class Model_Article extends ORML
{
// fields and methods here
}class Model_Article_Lang extends ORM
{
}
```Now you can access translated records using:
``` php
$article = ORML::factory('article');
$article->created // access to non translated fields
$article->updated
$article->translation->title // access to translated
$article->translation->content
```Remember to import schema and fixtures from tests/test_data/structure/test-schema-mysql.sql. Feel free to contribute.