Laravel-Lang / lang

List of 126 languages for Laravel Framework, Laravel Jetstream, Laravel Fortify, Laravel Breeze, Laravel Cashier, Laravel Nova, Laravel Spark and Laravel UI.

Home Page:https://laravel-lang.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

standard: locale should be zh_CN not zh-CN

sinkcup opened this issue · comments

commented

You can not set zh-CN as locale, it breaks the standard, it will failed, it should be converted to zh_CN.

So folders in this laravel/lang should use underline, e.g., zh_CN, pt_BR.

  • language tag: zh-CN
  • locale: zh_CN

https://www.php.net/manual/zh/function.setlocale.php

https://www.php.net/manual/zh/function.gettext.php

https://en.wikipedia.org/wiki/Locale_(computer_software)

On POSIX platforms such as Unix, Linux and others, locale identifiers are defined by ISO/IEC 15897, which is similar to the BCP 47 definition of language tags, but the locale variant modifier is defined differently, and the character set is included as a part of the identifier. It is defined in this format: [language[_territory][.codeset][@modifier]]. (For example, Australian English using the UTF-8 encoding is en_AU.UTF-8.)

$ locale --all
C
C.UTF-8
en_AG
en_AG.utf8
en_AU.utf8
en_BW.utf8
en_CA.utf8
en_DK.utf8
en_GB.utf8
en_HK.utf8
en_IE.utf8
en_IL
en_IL.utf8
en_IN
en_IN.utf8
en_NG
en_NG.utf8
en_NZ.utf8
en_PH.utf8
en_SG.utf8
en_US.utf8
en_ZA.utf8
en_ZM
en_ZM.utf8
en_ZW.utf8
POSIX
zh_CN.utf8
zh_SG.utf8

As I know, the language code has multiple standards. For Unix-like System, the habit is using "_" to concatenate two codes. Like you know, and I had the same question for some site URL(I use Linux too). You can entry Microsoft Website with zh-cn, zh-tw etc.


The Section - External links of Language code provide a link to list usual language codes. Provide to you.

At top of my root Blade-layout I have something like:

<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>

I mean, good that Laravel is consistence with HTML-standard
(instead of following Linux's underscore rule).

Note that I only visited this thread because, Laravel didn't anywhere mention the correct format,
out of:

  • zh_CN
  • zh-CN (correct one?)
  • zh_cn
  • zh-cn

@top-master, the official documentation mentions that Laravel, starting from version 6.0, is moving to support the ISO 15897 standard:

For languages that differ by territory, you should name the language directories according to the ISO 15897. For example, "en_GB" should be used for British English rather than "en-gb".

https://laravel.com/docs/9.x/localization#using-short-keys

So, the zh_CN variant is the correct ISO 15897 match.