turk-english-docs-translation/main.go

104 lines
3.3 KiB
Go
Raw Normal View History

2020-05-31 19:00:18 +00:00
package main
import (
"fmt"
"strconv"
"github.com/360EntSecGroup-Skylar/excelize/v2"
)
var nameSheet string
2020-05-31 19:00:18 +00:00
func main() {
langHashMap := make(map[string]string)
populateLanguageHash(langHashMap)
nameSheet = "assets/e-commerce/e-commerce-transactions"
convertTurkeyToEngLabel(nameSheet+".xlsx",
"Sheet1", langHashMap)
// exchangeHandler := initExhangeData()
// println(exchangeHandler["Some_key"].usd)
}
func convertTurkeyToEngLabel(fileName string, sheetName string, langHash map[string]string) {
//create new file for label conversion
fileLabelConversion := excelize.NewFile()
index := fileLabelConversion.NewSheet(sheetName)
//read from base xls file
file, err := excelize.OpenFile(fileName)
if err != nil {
fmt.Println(err)
return
}
// Get all the rows in base file
rows, err := file.GetRows(sheetName)
for rowIndex, row := range rows {
convertColumnItemsTurkeyToEng(row, langHash)
cellName := "A" + strconv.Itoa(rowIndex+1)
fileLabelConversion.SetSheetRow(sheetName, cellName, &row)
}
// Set active sheet of the workbook.
fileLabelConversion.SetActiveSheet(index)
// Save xlsx file by the given path.
if err := fileLabelConversion.SaveAs(nameSheet + "-eng.xlsx"); err != nil {
fmt.Println(err)
}
2020-05-31 19:00:18 +00:00
}
func convertColumnItemsTurkeyToEng(row []string, langHash map[string]string) {
for i, item := range row {
if value, ok := langHash[item]; ok {
row[i] = value
}
}
}
func populateLanguageHash(langHash map[string]string) {
2020-05-31 19:00:18 +00:00
langHash["Dönem"] = "period"
langHash["OCAK"] = "january"
langHash["ŞUBAT"] = "february"
langHash["MART"] = "March"
langHash["1. DÖNEM"] = "1st Quarter"
langHash["NISAN"] = "April"
langHash["MAYIS"] = "May"
langHash["HAZIRAN"] = "June"
langHash["2. DÖNEM"] = "2nd Quarter"
langHash["TEMMUZ"] = "July"
langHash["AĞUSTOS"] = "August"
2020-06-08 14:33:25 +00:00
langHash["EYLÜL"] = "September"
2020-05-31 19:00:18 +00:00
langHash["3. DÖNEM"] = "3rd Quarter"
langHash["EKIM"] = "October"
langHash["KASIM"] = "November"
langHash["ARALIK"] = "December"
langHash["4. DÖNEM"] = "4th Quarter"
langHash["2020 YILI"] = "2020 year"
langHash["2019 YILI"] = "2019 year"
langHash["2018 YILI"] = "2018 year"
langHash["2017 YILI"] = "2017 year"
langHash["2016 YILI"] = "2016 year"
langHash["2015 YILI"] = "2015 year"
langHash["2014 YILI"] = "2014 year"
langHash["2013 YILI"] = "2013 year"
langHash["2012 YILI"] = "2012 year"
langHash["2011 YILI"] = "2011 year"
langHash["İşlem Adedi"] = "Number of transaction over period"
langHash["İşlem Tutarı (Milyon TL)"] = "Volumn of transactions (Million TL)"
langHash["Alışveriş"] = "Purchase"
langHash["Nakit Çekme"] = "Cash"
langHash["Toplam"] = "Total"
langHash["Yerli Kartların Yurt İçi ve Yurtdışı Kullanımı"] = "Domestic and International Transactions with Domestic Cards"
langHash["Yerli ve Yabancı Kartların Yurt İçi Kullanımı"] = "Domestic Transactions with Domestic and International Cards"
langHash["Yerli Kartların Yurt İçi ve Yurtdışı Kullanımı"] = "Domestic and International Transactions with Domestic Cards"
langHash["Yerli ve Yabancı Kartların Yurt İçi Kullanımı"] = "Domestic Transactions with Domestic and International Cards"
langHash["Yurt İçi"] = "Domestic"
langHash["Yurtdışı"] = "Foreign"
langHash["Yerli Kart"] = "Domestic Card"
langHash["Yabancı Kart"] = "Foreign Card"
2020-05-31 19:00:18 +00:00
// langHash[""] = ""
}