-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Add i18n support for ActiveRecord #504
Comments
+1, in particular way, we need a way to handle with flexibility to date and time formats, which are often bad-definited in yii 1.* |
+1 i18n for ActiveRecord |
For reference, other implementations: |
+1 |
Vote against this feature in core. Multilingual behavior can be done through many ways. |
“i18n” is not correct name for the feature, which is described here. |
Looks like application design problem, not a framework one but if you have a good idea solving it once for all possible cases, it would be interesting. |
Just released a new implementation: http://www.yiiframework.com/extension/yii-i18n-attribute-messages/ |
@klimov-paul using your example there are still too many solutions to try to solve this in the framework. Consider a case when some records doesn't have one variant. Sometimes they need to be filtered out instead of using a default value. |
@nineinchnick I do not propose that any solution be included in the core, but all solutions to not limit/depend on the database schema (as long as we talk i18n only here, that is, not a general way to solve variation..). The i18n-attribute-messages solution simply uses the Yii::t() method and it thus not dependent on any particular database schema. It does however support saving translations if you use CDbMessageSource. Instead of returning a default value, one can use the onMissingTranslation handler to use null. |
should probably be an extension not a core feature. i haven't seen a PHP framework that has this as part of the core. |
is an extension like this available for yii2? |
not yet, as far as I know. |
@VinceG CakePHP has Translate behavior. |
I dont think it is a bad idea to create a connection between AR and the translation components. I have this implemented in my own projects and it has proven to be useful. Perhabs, even a connection to Object would be possible. Something like this:
This is so generic that it can be adopted in the core IMHO. Does anyone have similar implementations or ideas about this kind of architecture? |
Language should be canonicalized w/ |
hmmm...I think we are talking about 2 things here:
|
Nope. These two are the same. User added content is stored into attributes. |
can you elaborate? How should I see this.... |
I mean when you're saving any content it's saved into model attributes. I proposed a way to store these in a separate table depending on a language. The solution is good but you can't really automate it since it requires careful DB design. |
I tend to see a DB implementation out of the Yii's scope. We could start small with a architecture in which it is easy for a user to translate its AR attributes. |
What's AR attributes? Do you mean labels or what? |
yup |
Labels are already covered by Gii. There's a checkbox for wrapping em in |
alright, in that case its in the data scope and out of Yii's core scope. |
At the moment this can done via behaviors like the following:
http://www.yiiframework.com/extension/multilingual-behavior/
I18n handling is needed by most modern websites, so it would be great if it becomes part of the framework functionality.
The i18n table structure is already in use for Yii::t()
The text was updated successfully, but these errors were encountered: