From d9b52d97e6a826ac6c5f8e91a881b8d5d862ba7b Mon Sep 17 00:00:00 2001 From: Alan Date: Thu, 18 Apr 2024 12:19:57 +0800 Subject: [PATCH] fix #8131 - chinese translations --- Import/Timezone.php | 79 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Import/Timezone.php diff --git a/Import/Timezone.php b/Import/Timezone.php new file mode 100644 index 00000000..5c0f4b98 --- /dev/null +++ b/Import/Timezone.php @@ -0,0 +1,79 @@ +cli) { + die("cli only"); + } + } + + function get($part = '', $opts=array()) + { + $ce = DB_DataObject::factory('core_enum'); + $ce->query(" + SELECT + *, TIME_FORMAT(TIMEDIFF(NOW(), CONVERT_TZ(NOW(), Name, 'UTC')), '%H:%i') as timeOffset + FROM + mysql.time_zone_name + WHERE + Name LIKE '%/%' + AND + Name NOT LIKE '%/%/%' + AND + Name NOT LIKE 'right%' + AND + Name NOT LIKE 'posix%' + AND + Name NOT LIKE 'Etc%' + ORDER BY + SUBSTRING_INDEX(Name, '/', 1) ASC, + timeoffset ASC, + Name ASC + "); + + $values = array(); + + $regions = array(); + $areas = array(); + + while($ce->fetch()) { + $ar = explode('/', $ce->Name); + $region = $ar[0]; + $area = str_replace('_', ' ', $ar[1]); + + if(!in_array($region, $regions)) { + $regions[] = $region; + $values[] = "('Timezone.Region', '" . $region . "', 1, 0, 0, '" . $region . "', 0)"; + } + + if(!in_array($area, $areas)) { + $areas[] = $area; + $values[] = "('Timezone.Area', '" . $area . "', 1, 0, 0, '" . $area . "', 0)"; + } + } + + $sql = " + INSERT INTO + core_enum (etype, name, active, seqid, seqmax, display_name, is_system_enum) + VALUES + " . implode(", \n", $values) . " + "; + + $ce = DB_DataObject::factory('core_enum'); + $ce->query($sql); + + $this->jok('DONE'); + } +} \ No newline at end of file -- 2.39.2