cocoapods-aqara-localzedLoader 0.1.16 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c557d47179504b09a3ce83e5249bc53770e57e8381afc9083fa98d3536787b44
4
- data.tar.gz: e27468da9cb5661d6b3c386b80086795331739e98cff87f4969064c25d0692a9
3
+ metadata.gz: 0014ff7ca1b9fd3a2e93e4adede8455537da274e28704c3523fd357eebb86aab
4
+ data.tar.gz: 5066c47affcedfa80643d8fee28f85655656675063561d2de542299c753829a1
5
5
  SHA512:
6
- metadata.gz: bf0d7310384c515dc492b01409b9fae7fe2f52f90bd9410713edacce678130e5428cc1a36ba041fae7d96feada5fee9cb52400635311ee4611788c7b49b4e97e
7
- data.tar.gz: 2324c2bf0ae30d9c31bfb049698b6314d5233a40f81bcde8319c57629591093bd73e1d7e658d42ce5bd4d1d3d9c9123c7718dfd1c08925e456e4f4d6b2d3c8ea
6
+ metadata.gz: 98720fd614a55a077693d8d72fb16434d4cf494a7c8686947697d006e298c76cc7f92b40ce5dab0c4ea3c225a278a2de3af2b32519af9e2c4cf55d46a4326ab0
7
+ data.tar.gz: d62b44c11a5fa882981f5bebfb3c0c0137994b2c995916c914900df6b980c0afba617841bac64d8752a92eb6b02cc29da23a5b3532f6fb598f7d4e0f1d52f8f4
@@ -3,9 +3,7 @@ import os, sys, stat
3
3
  import time
4
4
  import requests
5
5
  import zipfile
6
- import csv
7
6
  from typing import Optional
8
- from openpyxl import Workbook
9
7
 
10
8
 
11
9
  ######### 火山多语言 #############
@@ -268,17 +266,18 @@ class CrowdinPlatform():
268
266
  os.remove(zip_path)
269
267
 
270
268
  if self.project_id == DEFAULT_LIFE_PROJECT_ID:
271
- csv_path = find_life_csv_file(output_dir)
272
- if not csv_path:
273
- raise FileNotFoundError(f"未找到 Life 项目的 CSV 文件: {output_dir}")
274
-
269
+ life_xlsx_path = os.path.join(output_dir, DEFAULT_LIFE_SOURCE_FILE_NAME)
275
270
  xlsx_path = os.path.join(output_dir, DEFAULT_TARGET_FILE_NAME)
276
- convert_csv_to_xlsx(csv_path, xlsx_path)
271
+ if not os.path.exists(life_xlsx_path):
272
+ raise FileNotFoundError(f"未找到 Life 项目的 Excel 文件: {life_xlsx_path}")
273
+ os.replace(life_xlsx_path, xlsx_path)
274
+ print(f"已将 Life 多语言文件重命名为: {xlsx_path}")
277
275
 
278
276
  print(f"多语言文件已解压到: {output_dir}APP.xlsx")
279
277
 
280
278
  DEFAULT_LEGACY_PROJECT_ID = "71"
281
279
  DEFAULT_LIFE_PROJECT_ID = "85"
280
+ DEFAULT_LIFE_SOURCE_FILE_NAME = "APP_Life_APP.xlsx"
282
281
  DEFAULT_TARGET_FILE_NAME = "APP.xlsx"
283
282
 
284
283
  CROWDIN_PROJECTS = (
@@ -314,83 +313,6 @@ def resolve_crowdin_access_token(cli_token: Optional[str] = None) -> str:
314
313
  return access_token
315
314
 
316
315
 
317
- def find_life_csv_file(output_dir: str) -> Optional[str]:
318
- preferred_path = os.path.join(output_dir, "APP_Life_APP.csv")
319
- if os.path.exists(preferred_path):
320
- return preferred_path
321
-
322
- fallback_csv_paths = []
323
- for root, _, file_names in os.walk(output_dir):
324
- for file_name in sorted(file_names):
325
- file_path = os.path.join(root, file_name)
326
- if file_name == "APP_Life_APP.csv":
327
- return file_path
328
- if file_name.lower().endswith(".csv"):
329
- fallback_csv_paths.append(file_path)
330
-
331
- if fallback_csv_paths:
332
- return fallback_csv_paths[0]
333
- return None
334
-
335
-
336
- def convert_csv_to_xlsx(csv_path: str, xlsx_path: str) -> None:
337
- with open(csv_path, "r", encoding="utf-8-sig", newline="") as csv_file:
338
- sample = csv_file.read(4096)
339
- csv_file.seek(0)
340
-
341
- try:
342
- dialect = csv.Sniffer().sniff(sample)
343
- except csv.Error:
344
- dialect = csv.excel
345
-
346
- reader = csv.reader(csv_file, dialect)
347
- workbook = Workbook()
348
- worksheet = workbook.active
349
-
350
- rows = list(reader)
351
- if not rows:
352
- workbook.save(xlsx_path)
353
- print(f"已将空 CSV 转换为 Excel: {xlsx_path}")
354
- return
355
-
356
- # 统一成旧项目 APP.xlsx 的列结构:
357
- # keys | source | tag | length limit | context | en-US | ...
358
- normalized_rows = []
359
- for row_index, row in enumerate(rows):
360
- normalized_row = []
361
- keys_value = row[0] if len(row) > 0 else ""
362
- source_value = row[1] if len(row) > 1 else ""
363
- context_value = row[2] if len(row) > 2 else ""
364
- remaining_values = list(row[3:]) if len(row) > 3 else []
365
-
366
- if row_index == 0:
367
- normalized_row = [
368
- "keys",
369
- "source",
370
- "tag",
371
- "length limit",
372
- "context",
373
- "en-US",
374
- ]
375
- normalized_row.extend(remaining_values[1:])
376
- else:
377
- normalized_row = [
378
- keys_value,
379
- source_value,
380
- "",
381
- "",
382
- context_value,
383
- ]
384
- normalized_row.extend(remaining_values)
385
- normalized_rows.append(normalized_row)
386
-
387
- for row in normalized_rows:
388
- worksheet.append(row)
389
-
390
- workbook.save(xlsx_path)
391
- print(f"已将 CSV 转换为 Excel: {xlsx_path}")
392
-
393
-
394
316
  ############################
395
317
 
396
318
  def str_to_bool(v: str) -> bool:
@@ -1,3 +1,3 @@
1
1
  module Localzedloader
2
- VERSION = "0.1.16"
2
+ VERSION = "0.1.17"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cocoapods-aqara-localzedLoader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.16
4
+ version: 0.1.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - zhaoxifan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-02 00:00:00.000000000 Z
11
+ date: 2026-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler