|
@@ -64,13 +64,13 @@ def process_batch_translations(data, search_term_index, category_indices):
|
|
|
|
|
|
|
|
# 收集所有需要翻译的文本
|
|
# 收集所有需要翻译的文本
|
|
|
translation_batches = {
|
|
translation_batches = {
|
|
|
- 'search_terms': [row[search_term_index] for row in data[1:]],
|
|
|
|
|
|
|
+ 'search_terms': [row[search_term_index] for row in data[2:]], # 从第三行开始
|
|
|
'categories': []
|
|
'categories': []
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
# 收集类别翻译
|
|
# 收集类别翻译
|
|
|
for index in category_indices:
|
|
for index in category_indices:
|
|
|
- translation_batches['categories'].extend([row[index] for row in data[1:]])
|
|
|
|
|
|
|
+ translation_batches['categories'].extend([row[index] for row in data[2:]]) # 从第三行开始
|
|
|
|
|
|
|
|
# 批量翻译
|
|
# 批量翻译
|
|
|
logger.info("Starting batch translations...")
|
|
logger.info("Starting batch translations...")
|
|
@@ -79,17 +79,17 @@ def process_batch_translations(data, search_term_index, category_indices):
|
|
|
logger.info("Batch translations completed")
|
|
logger.info("Batch translations completed")
|
|
|
|
|
|
|
|
# 更新数据
|
|
# 更新数据
|
|
|
- for i, row in enumerate(data[1:], start=1):
|
|
|
|
|
|
|
+ for i, row in enumerate(data[2:], start=2): # 从第三行开始处理
|
|
|
try:
|
|
try:
|
|
|
# 更新搜索词翻译列
|
|
# 更新搜索词翻译列
|
|
|
- row[search_term_index + 1] = search_translations[i-1]
|
|
|
|
|
|
|
+ row[search_term_index + 1] = search_translations[i-2]
|
|
|
|
|
|
|
|
- # 添加亚马逊搜索链接
|
|
|
|
|
|
|
+ # 添加亚马逊搜索链接(跳过标题行)
|
|
|
amazon_url = f"https://www.amazon.co.jp/s?k={row[search_term_index]}"
|
|
amazon_url = f"https://www.amazon.co.jp/s?k={row[search_term_index]}"
|
|
|
row[search_term_index] = create_hyperlink(row[search_term_index], amazon_url)
|
|
row[search_term_index] = create_hyperlink(row[search_term_index], amazon_url)
|
|
|
|
|
|
|
|
# 更新类别翻译
|
|
# 更新类别翻译
|
|
|
- category_trans_index = 0
|
|
|
|
|
|
|
+ category_trans_index = (i-2) * len(category_indices)
|
|
|
for cat_index in category_indices:
|
|
for cat_index in category_indices:
|
|
|
row[cat_index + 1] = category_translations[category_trans_index]
|
|
row[cat_index + 1] = category_translations[category_trans_index]
|
|
|
category_trans_index += 1
|
|
category_trans_index += 1
|
|
@@ -106,7 +106,7 @@ def process_batch_translations(data, search_term_index, category_indices):
|
|
|
def add_brand_asin_links(data, brand_indices, asin_indices):
|
|
def add_brand_asin_links(data, brand_indices, asin_indices):
|
|
|
"""为品牌和ASIN列添加链接"""
|
|
"""为品牌和ASIN列添加链接"""
|
|
|
try:
|
|
try:
|
|
|
- for row in data[1:]:
|
|
|
|
|
|
|
+ for row in data[2:]: # 从第三行开始处理
|
|
|
# 处理品牌列
|
|
# 处理品牌列
|
|
|
for index in brand_indices:
|
|
for index in brand_indices:
|
|
|
if index < len(row) and row[index]:
|
|
if index < len(row) and row[index]:
|