Efficient coding with Yii implies efficient use of the code generator. This article shares the personalised Gii templates that were built starting from the standard templates proposed by AweGen.
Efficient coding with Yii implies efficient use of the code generator. This article shares the personalised Gii templates that were built starting from the standard templates proposed by AweGen.
A simple trick to get the localized version of a model field is to add this little method to your models.
The giix code generator has out of the box i18n support for model names and attribute labels (besides other cool features > check it out!) .
But I want to factor in not only the plural form, but also the grammatical cases (especially the accusative) while translating 'Manage Objects', 'Create Object', 'Edit Object' etc.
I needed all messages with their translation into javascript. This is my solution:
When using themes you want to changes some of the translations specifically to the theme while keeping the standard translations for most of the text. Duplicating the main translation file is a headache for maintainance. This how to provides a solution.
Example settings when using Gettext for i18n.
Yii 2.0 comes with a formatter component to format dates, numbers, and other values for international users according to their locale. This is very useful for displaying data. When working with incoming data or when using enhanced input methods like the [MaskedInput widget](https://www.yiiframework.com/doc/api/2.0/yii-widgets-maskedinp...
The number of languages supported by the standard CJuiDatePicker implementation is limited and the language code to use is different from the application's language code. This Wiki shows how to improve on that.
Your application is international and you have to select the best language for the user. Your user may have selected 'fr_CA' and you have 'fr_FR' or 'fr' available. What do you do? Here is a tip.
Sometimes you want to use exisiting translations for locales, which do not directly match. An example would be a website targeting Germany (de_de), Austria (de_at) and Switzerland (de_ch, fr_ch, it_ch). Although you may have exisiting translations for German (de), French (fr) and Italian (it), there are problems using it directly.
In your application configuration (protected/config/main.php), set the sourceLanguage parameter to English:
common\components\LanguageSelector.php
<?php
namespace common\components;
This topic is related with langhandler extension
Yii comes with internationalisation (i18n) "out of the box". There are instructions in the manual as to how to configure Yii to use i18n, but little information all in one place on how to fully integrate it into the bootstrap menu. This document attempts to remedy that.
Language translation is a common requirement in multi lingual sites. In Yii, we can translate using message and view translation.
As you know, the CDetailView widget displays details of a single model. If no formatting is specified, boolean values that are stored in the database as 0 and 1, are represented in the detail view as 0 and 1. If formatted as boolean, they are represented as 'No' and 'Yes'. We want to add i18n support, so that Yes and No appear in the current language.
So here is my complete solution - note that I'm using the 'short' date format throughout.
There are scenarios when you work with DVCS (like [Mercurial]( http://mercurial.selenic.com/) or [Git]( http://git-scm.com/)) and CDbMessageSource. To my experience keeping the development database and production database in sync can be very...