Answer the question
In order to leave comments, you need to log in
Kohana & I18n. Is it possible to split a language file into parts?
In any project, there are some common phrases for all controllers (for example, “edit”, “add comment”, etc.), but the controller itself may have its own set of phrases that are not needed anywhere else. Therefore, I thought, is it possible to split the language file into parts and load any one as needed. That is, the structure of the language files will be as follows:
= /application
== /i18n
=== /ru
==== common.php
==== forum.php
==== users.php
common.php is a file with common phrases, so I included it in bootstrap like this I18n::lang('ru-common');
But now I don't know how to connect the language file for forum.
<?php defined('SYSPATH') or die('No direct script access.');<br/>
<br/>
class Controller_Forum extends Controller{<br/>
<br/>
public function action_index()<br/>
{<br/>
I18n::lang('ru-forum'); // таким образом файл поддключается но перекрывает собой common.php и поэтому "hello world" не переводится<br/>
echo __('hello world');<br/>
echo __('hello forum');<br/>
}<br/>
<br/>
} // End Forum<br/>
<br/>
Answer the question
In order to leave comments, you need to log in
To be honest, I don’t see the point in such an “optimization”. A typical practice is to move translations into the necessary modules, this makes sense if there is a Forum module, a Blog module, etc. Accordingly, if the Forum module is not connected, then its I18n files will not be connected either.
I would advise not to invent dishish problems :)
I wanted to write about gettext and dgettext, but it turned out that Kohana uses its own implementation of multilingualism.
Try
echo __('hello world', null, 'ru-common');
echo __('hello forum', null, 'ru-forum');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question