Mark Ku's Blog

Using PowerShell to download Google Sheets and generate i18n JSON files

Problem

As enterprise architectures grow more complex, different roles and applications often need to maintain the same set of translation files during development.

How it works

Google Sheets gives you collaborative editing for free. By exporting the sheet as CSV and downloading it locally, PowerShell can read the CSV, transform it into i18n JSON objects, and write them out.

First, use Google Sheets to enable collaboration

  1. Create a new Google Sheet
    https://docs.google.com/spreadsheets/d/192ji-2k1XHOdXYBu8fD7wNSAnz-eKcdQB57LR66quTg

  2. Set the share permissions so that anyone with the link can access it Google Sheet with sharing dialog showing anyone with link access

Write the PowerShell script

$filepath = './Rawi18nFile.csv'

& { 
 (new-object net.webclient).downloadfile('https://docs.google.com/spreadsheets/d/192ji-2k1XHOdXYBu8fD7wNSAnz-eKcdQB57LR66quTg/export?format=csv', $filepath)
}

$translate = @{}

$NewCsvData= Import-CSV $filepath  | Foreach-Object{       
   
    foreach ($property in $_.PSObject.Properties)
    {
		if($property.Name  -eq 'Module' )
		{
			$module =	$property.Value
			continue
		}
		
		if($property.Name -eq 'Key')
		{		
			$key =	$property.Value
			continue
		}		
				
		$mainKey ="$module.$key";
			
		if (!$translate.ContainsKey($property.Name)) {			
			$translate[$property.Name]= @{}			
		}	
	
		 $translate[$property.Name][$mainKey]  = $property.Value			        
    }           
}

forEach($lang in $translate.Keys){    
	$translate[$lang] | ConvertTo-Json  | % { [System.Text.RegularExpressions.Regex]::Unescape($_) } | new-item -force  "./output/$lang.json"  
}

Result

  1. Right-click > Run with PowerShell Windows right-click menu showing 'Run with PowerShell' option

  2. PowerShell reports success PowerShell window listing generated i18n JSON files

  3. The i18n locale files appear in the output folder Notepad++ displaying a Korean i18n JSON file with error messages

Author

Mark Ku

擁有 10+ 年經驗的資深軟體工程師,現為 AI 應用 Builder,專注於大型平台架構與簡化複雜系統設計,從電商系統到訂閱與收費平台,結合 AI Agent、AI 整合與自動化開發,打造高效率且可持續演進的產品技術基礎。Read More

Found this useful?

The author's free tools, daily podcasts and newsletter are all here.

Mark Ku · This article is licensed under CC BY 4.0. Credit the author and link back to the original when reusing it.

Comments

Subscribe to Newsletter

Subscribe to get new posts delivered instantly — never miss a tech share.

By submitting, you agree to receive emails. You can anytime.

Popular Posts

View all
Mark Ku
··601

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution

Oracle Cloud Always Free Tier: Linux Host and Static IP for a $0 Cloud Solution
Mark Ku
··441

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.

Say Goodbye to Postman's Fee Trap! A Hands-on Guide to Bruno, the Open-Source Git-Native API Testing Powerhouse.
Mark Ku
··318

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki

A Free, Open-Source, Notion-like Knowledge Base — A Complete Guide to Deploying and Backing Up Outline Wiki
Mark Ku
··239

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1

Building an Efficient API Management Platform: Deploying Kong Gateway from Scratch - Part 1
Mark Ku
··223

Setting Up Samba on Ubuntu to Share Folders with Windows 11

Setting Up Samba on Ubuntu to Share Folders with Windows 11
Mark Ku
··202

訓練自己的 AI 語音:硬體門檻、開源模型比較與 LoRA 微調

訓練自己的 AI 語音:硬體門檻、開源模型比較與 LoRA 微調