Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(#2): removed modified property in translation file #121

Merged
merged 3 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions examples/demo1-i18n/demo1.go.en.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go"
},
{
"id": "Version {{.Arg0}}n",
"translation": "Version {{.Arg0}}n"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/en.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/de.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hallo von Goffer Land und i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hallo von Goffer Land und i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/de_DE.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hallo von Goffer Land und i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hallo von Goffer Land und i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/en_US.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Hello from Goffer land and i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/es.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Saludos desde la tierra Goffer y i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Versión {{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Saludos desde la tierra Goffer y i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Versión {{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/es_ES.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Saludos desde la tierra Goffer y i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Versión {{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Saludos desde la tierra Goffer y i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Versión {{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/fr.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Bonjour de la terre et Goffer i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Bonjour de la terre et Goffer i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/fr_FR.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Bonjour de la terre des Goffer land et de i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "Bonjour de la terre des Goffer land et de i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "Version {{.Arg0}}\n"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/zh.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "你好,从高佛尔的土地和i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "版本{{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "你好,从高佛尔的土地和i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "版本{{.Arg0}}"
}
]
20 changes: 9 additions & 11 deletions examples/demo1-i18n/i18n/resources/zh_Hans.all.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
[
{
"id": "Hello from Goffer land and i18n4go",
"translation": "你好,从高佛尔的土地和i18n4go",
"modified": false
},
{
"id": "Version {{.Arg0}}\n",
"translation": "版本{{.Arg0}}",
"modified": false
}
]
{
"id": "Hello from Goffer land and i18n4go",
"translation": "你好,从高佛尔的土地和i18n4go"
},
{
"id": "Version {{.Arg0}}\n",
"translation": "版本{{.Arg0}}"
}
]
2 changes: 1 addition & 1 deletion i18n4go/cmds/fixup.go
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ func updateTranslations(localMap map[string]common.I18nStringInfo, localeFile st
if locale == "en_US" {
localMap[value] = common.I18nStringInfo{ID: value, Translation: value}
} else {
localMap[value] = common.I18nStringInfo{ID: value, Translation: localMap[key].Translation, Modified: true}
localMap[value] = common.I18nStringInfo{ID: value, Translation: localMap[key].Translation}
}
delete(localMap, key)
}
Expand Down
1 change: 0 additions & 1 deletion i18n4go/common/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ type Options struct {
type I18nStringInfo struct {
ID string `json:"id"`
Translation string `json:"translation"`
Modified bool `json:"modified"`
}

type StringInfo struct {
Expand Down
4 changes: 0 additions & 4 deletions integration/extract_strings/s_option_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,11 @@ var _ = Describe("extract-strings -s filePath", func() {
Ω(translations).To(ContainElement(common.I18nStringInfo{
ID: "a string",
Translation: "a string",
Modified: false,
}))

Ω(translations).To(ContainElement(common.I18nStringInfo{
ID: "show the app details",
Translation: "show the app details",
Modified: false,
}))
})
})
Expand Down Expand Up @@ -119,13 +117,11 @@ var _ = Describe("extract-strings -s filePath", func() {
Ω(translations).To(ContainElement(common.I18nStringInfo{
ID: "a string",
Translation: "a string",
Modified: false,
}))

Ω(translations).To(ContainElement(common.I18nStringInfo{
ID: "show the app details",
Translation: "show the app details",
Modified: false,
}))
})
})
Expand Down
5 changes: 2 additions & 3 deletions integration/fixup/fixup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,14 +267,13 @@ var _ = Describe("fixup", func() {
mappedTranslations, err := common.CreateI18nStringInfoMap(translations)
Ω(err).ShouldNot(HaveOccurred())

Ω(mappedTranslations["I like apples."].Modified).Should(BeTrue())
Ω(mappedTranslations["I like apples."].Translation).ShouldNot(Equal("I like apples."))
})
})

Context("When the user says the translation is new", func() {
var (
apple = common.I18nStringInfo{ID: "I like apples.", Translation: "I like apples.", Modified: false}
apple = common.I18nStringInfo{ID: "I like apples.", Translation: "I like apples."}
)

JustBeforeEach(func() {
Expand Down Expand Up @@ -315,7 +314,7 @@ var _ = Describe("fixup", func() {
mappedTranslations, err := common.CreateI18nStringInfoMap(translations)
Ω(err).ShouldNot(HaveOccurred())
Ω(mappedTranslations["I'm the extra key"]).Should(Equal(
common.I18nStringInfo{ID: "I'm the extra key", Translation: "I'm the extra key", Modified: false},
common.I18nStringInfo{ID: "I'm the extra key", Translation: "I'm the extra key"},
))
})
})
Expand Down
Loading