Skip to content

Conversation

@basil-inc
Copy link
Contributor

Currently, the layout of the basic and advanced app templates has English hardcoded as language:

<html lang="EN">

Since language is a dynamic attribute in the application config. Based on Paul's suggestion, I propose to use this:

<html lang="<?= str_replace('_', '-', Yii::$app->language) ?>">

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.38%) when pulling 65570f7 on docsolver:master into 2c92fc8 on yiisoft:master.

@klimov-paul
Copy link
Member

Fix is not exactly correct. For the language dialects it would produce invalid HTML.
Locale language code format uses underscore (_) as separator, while HTML uses dash (-).
For example: locale language code “en_us”, should have HTML code “en-us”.
You may use following:

str_replace('_', '-', \Yii::app()->language);

@basil-inc
Copy link
Contributor Author

Okay, I changed the commits. I must confess it doesn't look very elegant. Why can't we also use languages with dashes internally?

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.38%) when pulling 944f2ed on docsolver:master into 2c92fc8 on yiisoft:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) when pulling 944f2ed on docsolver:master into 2c92fc8 on yiisoft:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.03%) when pulling 944f2ed on docsolver:master into 2c92fc8 on yiisoft:master.

@iJackUA
Copy link
Contributor

iJackUA commented Nov 19, 2013

I would rather "hide" this logic str_replace('_', '-', \Yii::app()->language) from template to some method in yii\web\View for example

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) when pulling 58b4380 on docsolver:master into 2c92fc8 on yiisoft:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.43%) when pulling 58b4380 on docsolver:master into 2c92fc8 on yiisoft:master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) when pulling 58b4380 on docsolver:master into 2c92fc8 on yiisoft:master.

@qiangxue
Copy link
Member

@cebe @samdark Do you see any problem with intl if we use dash instead of underscore to separate language and country, e.g., en-US instead of en_US?

@qiangxue qiangxue closed this in d2e5f2c Nov 19, 2013
@qiangxue
Copy link
Member

Never mind. intl works with both dash and underscore. Dash separator is more popular.

@samdark
Copy link
Member

samdark commented Nov 19, 2013

Yeah, I've just verified that.

qiansen1386 pushed a commit to qiansen1386/yii2 that referenced this pull request Mar 9, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants