Skip to content

M2.2.3 directory_country_region_name locale fix? 8bytes zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes) #14001

Closed
@jiyun

Description

@jiyun

Preconditions

Perhaps it is English, French, German, Italian and so Latin. Shorthand notation is short (en_US 5 bytes)
The various dialects of Chinese are limited by the length of the field? zh_Hans_CN(11bytes) ca_ES_VALENCIA(14bytes)

directory_country_region_name locale 8bytes

Steps to reproduce

zh_Hans_CN” ->directory_country_region_name locale == “zh_Hans_
Invalid after restricted character truncation

Problem path:
app/code/Magento/Directory/Setup/InstallSchema.php:143

        $table = $installer->getConnection()->newTable(
            $installer->getTable('directory_country_region_name')
        )->addColumn(
            'locale',
            \Magento\Framework\DB\Ddl\Table::TYPE_TEXT,
            8,
            ['nullable' => false, 'primary' => true, 'default' => false],
            'Locale'

Expected result

Change to 14 known valid byte or 16? or only 11 bytes of Chinese zh_hans_xx

Just change it. We are doing Chinese localization Magento2 will be convenient for many

Actual result

New additional data
app/code/Magento/Directory/Setup/InstallSchema.php

//中国省级地址
        $datacn = [
            ['CN','11','BJ','京','Beijing','北京市'],
            ['CN','12','TJ','津','Tianjing','天津市'],
            ['CN','13','HE','冀','Hebei','河北省'],
            ['CN','14','SX','晋','Shanxi','山西省'],
            ['CN','15','NM','蒙','Inner Mongoria','内蒙古自治区'],
            ['CN','21','LN','辽','Liaoning','辽宁省'],
            ['CN','22','JL','吉','Jilin','吉林省'],
            ['CN','23','HL','黑','Heilongjiang','黑龙江省'],
            ['CN','31','SH','沪','Shanghai','上海市'],
            ['CN','32','JS','苏','Jiangsu','江苏省'],
            ['CN','33','ZJ','浙','Zhejiang','浙江省'],
            ['CN','34','AN','皖','Anhui','安徽省'],
            ['CN','35','FJ','闽','Fujian','福建省'],
            ['CN','36','JX','赣','Jiangxi','江西省'],
            ['CN','37','SD','鲁','Shandong','山东省'],
            ['CN','41','HA','豫','Henan','河南省'],
            ['CN','42','HB','鄂','Hubei','湖北省'],
            ['CN','43','HN','湘','Hunan','湖南省'],
            ['CN','44','GD','粤','Guangdong','广东省'],
            ['CN','45','GX','桂','Guangxi','广西壮族自治区'],
            ['CN','46','HI','琼','Hainan','海南省'],
            ['CN','50','CQ','渝','Chongqing','重庆市'],
            ['CN','51','SC','川','Sichuan','四川省'],
            ['CN','52','GZ','贵','Guizhou','贵州省'],
            ['CN','53','YN','云','Yunnan','云南省'],
            ['CN','54','XZ','藏','Tibet','西藏自治区'],
            ['CN','61','SN','陕','Shaanxi','陕西省'],
            ['CN','62','GS','甘','Gansu','甘肃省'],
            ['CN','63','QH','青','Qinghai','青海省'],
            ['CN','64','NX','宁','Ningxia','宁夏回族自治区'],
            ['CN','65','XJ','新','Xinjiang','新疆维吾尔自治区'],
            ['CN','71','TW','台','Taiwan','台湾省'],
            ['CN','81','HK','港','Hong Kong','香港特别行政区'],
            ['CN','82','MO','澳','Macao ','澳门特别行政区']
//ISO标准国家缩写0,国标省级数字编码1,国标省级域名缩写2,国标省级单字缩写(车牌)3,国标省级英文4,国标省级全称5。
		];
        foreach ($datacn as $row) {
            $bind = ['country_id' => $row[0], 'code' => $row[2], 'default_name' => $row[4]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region'), $bind);
            $regionId = $setup->getConnection()->lastInsertId($setup->getTable('directory_country_region'));
            $bind = ['locale' => 'en_US', 'region_id' => $regionId, 'name' => $row[4]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
            $bind = ['locale' => 'zh_Hans_CN', 'region_id' => $regionId, 'name' => $row[5]];
            $setup->getConnection()->insert($setup->getTable('directory_country_region_name'), $bind);
        }

Error effect
1

Before
Database pic
1
2

Target effect
2

Modified After
Database pic
3
4

Metadata

Metadata

Assignees

Labels

Component: DirectoryFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentProgress: PR CreatedIndicates that Pull Request has been created to fix issueReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchhelp wanted

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions