diff --git a/integration/fixup/fixup_test.go b/integration/fixup/fixup_test.go index b05ffa0..2289143 100644 --- a/integration/fixup/fixup_test.go +++ b/integration/fixup/fixup_test.go @@ -82,7 +82,6 @@ var _ = Describe("fixup", func() { panic(err.Error()) } - //session = Runi18n("-c", "fixup") cmd = exec.Command(I18n4goExec, "-c", "fixup") stdinPipe, err = cmd.StdinPipe() @@ -163,11 +162,11 @@ var _ = Describe("fixup", func() { exitCode := cmd.Wait() Ω(exitCode).Should(BeNil()) - file, err := ioutil.ReadFile(filepath.Join(".", "translations", "en_US.all.json")) + file, err := ioutil.ReadFile(filepath.Join(".", "translations", "all.en_US.json")) Ω(err).ShouldNot(HaveOccurred()) Ω(file).Should(ContainSubstring("\"Heal the world\"")) - chineseFile, err := ioutil.ReadFile(filepath.Join(".", "translations", "zh_CN.all.json")) + chineseFile, err := ioutil.ReadFile(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) Ω(chineseFile).Should(ContainSubstring("\"Heal the world\"")) }) @@ -185,11 +184,11 @@ var _ = Describe("fixup", func() { exitCode := cmd.Wait() Ω(exitCode).Should(BeNil()) - file, err := ioutil.ReadFile(filepath.Join(".", "translations", "en_US.all.json")) + file, err := ioutil.ReadFile(filepath.Join(".", "translations", "all.en_US.json")) Ω(err).ShouldNot(HaveOccurred()) Ω(file).ShouldNot(ContainSubstring("\"Heal the world\"")) - chineseFile, err := ioutil.ReadFile(filepath.Join(".", "translations", "zh_CN.all.json")) + chineseFile, err := ioutil.ReadFile(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) Ω(chineseFile).ShouldNot(ContainSubstring("\"Heal the world\"")) }) @@ -234,14 +233,14 @@ var _ = Describe("fixup", func() { It("Updates the keys for all translation files", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "en_US.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.en_US.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) Ω(mappedTranslations["I like bananas."]).Should(Equal(common.I18nStringInfo{})) Ω(mappedTranslations["I like apples."]).ShouldNot(Equal(common.I18nStringInfo{})) - translations, err = common.LoadI18nStringInfos(filepath.Join(".", "translations", "zh_CN.all.json")) + translations, err = common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err = common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -252,7 +251,7 @@ var _ = Describe("fixup", func() { It("Updates all the translation", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "en_US.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.en_US.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -262,7 +261,7 @@ var _ = Describe("fixup", func() { It("marks the foreign language translations as updated", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "zh_CN.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -284,14 +283,14 @@ var _ = Describe("fixup", func() { It("adds the new translation and deletes the old translation from all translation files", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "en_US.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.en_US.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) Ω(mappedTranslations["I like bananas."]).Should(Equal(common.I18nStringInfo{})) Ω(mappedTranslations["I like apples."]).Should(Equal(apple)) - translations, err = common.LoadI18nStringInfos(filepath.Join(".", "translations", "zh_CN.all.json")) + translations, err = common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err = common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -309,7 +308,7 @@ var _ = Describe("fixup", func() { It("adds the extra translation", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "zh_CN.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -327,7 +326,7 @@ var _ = Describe("fixup", func() { It("removes the extra translation", func() { cmd.Wait() - translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "zh_CN.all.json")) + translations, err := common.LoadI18nStringInfos(filepath.Join(".", "translations", "all.zh_CN.json")) Ω(err).ShouldNot(HaveOccurred()) mappedTranslations, err := common.CreateI18nStringInfoMap(translations) Ω(err).ShouldNot(HaveOccurred()) @@ -344,7 +343,7 @@ func storeTranslationFiles(dir string) (files map[string][]byte, err error) { if !fileInfo.IsDir() { name := fileInfo.Name() - if strings.HasSuffix(name, ".all.json") { + if strings.HasPrefix(name, "all.") { path := filepath.Join(dir, fileInfo.Name()) files[path], err = ioutil.ReadFile(path) diff --git a/test_fixtures/fixup/allgood/translations/all.en_US.json b/test_fixtures/fixup/allgood/translations/all.en_US.json new file mode 100644 index 0000000..2dfd192 --- /dev/null +++ b/test_fixtures/fixup/allgood/translations/all.en_US.json @@ -0,0 +1,6 @@ +[ + { + "id": "Translated hello world!", + "translation": "Translated hello world!" + } +] \ No newline at end of file diff --git a/test_fixtures/fixup/allgood/translations/all.zh_CN.json b/test_fixtures/fixup/allgood/translations/all.zh_CN.json new file mode 100644 index 0000000..9ed6605 --- /dev/null +++ b/test_fixtures/fixup/allgood/translations/all.zh_CN.json @@ -0,0 +1,6 @@ +[ + { + "id": "Translated hello world!", + "translation": "你好世界!" + } +] \ No newline at end of file diff --git a/test_fixtures/fixup/allgood/translations/en_US.all.json b/test_fixtures/fixup/allgood/translations/en_US.all.json deleted file mode 100644 index 38485bb..0000000 --- a/test_fixtures/fixup/allgood/translations/en_US.all.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "id": "Translated hello world!", - "translation": "Translated hello world!" - } -] diff --git a/test_fixtures/fixup/allgood/translations/zh_CN.all.json b/test_fixtures/fixup/allgood/translations/zh_CN.all.json deleted file mode 100644 index 8339aca..0000000 --- a/test_fixtures/fixup/allgood/translations/zh_CN.all.json +++ /dev/null @@ -1,6 +0,0 @@ -[ - { - "id": "Translated hello world!", - "translation": "你好世界!" - } -] diff --git a/test_fixtures/fixup/notsogood/add/translations/en_US.all.json b/test_fixtures/fixup/notsogood/add/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/add/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/add/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/add/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/add/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/add/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/add/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/delete/translations/en_US.all.json b/test_fixtures/fixup/notsogood/delete/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/delete/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/delete/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/delete/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/delete/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/delete/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/delete/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/extra_foreign_key/translations/en_US.all.json b/test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/extra_foreign_key/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/extra_foreign_key/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/extra_foreign_key/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/extra_foreign_key/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/missing_foreign_key/translations/en_US.all.json b/test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/missing_foreign_key/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/missing_foreign_key/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/missing_foreign_key/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/missing_foreign_key/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/multiple_update/translations/en_US.all.json b/test_fixtures/fixup/notsogood/multiple_update/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/multiple_update/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/multiple_update/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/multiple_update/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/multiple_update/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/multiple_update/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/multiple_update/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/update/translations/en_US.all.json b/test_fixtures/fixup/notsogood/update/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/update/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/update/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/update/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/update/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/update/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/update/translations/all.zh_CN.json diff --git a/test_fixtures/fixup/notsogood/update_add/translations/en_US.all.json b/test_fixtures/fixup/notsogood/update_add/translations/all.en_US.json similarity index 100% rename from test_fixtures/fixup/notsogood/update_add/translations/en_US.all.json rename to test_fixtures/fixup/notsogood/update_add/translations/all.en_US.json diff --git a/test_fixtures/fixup/notsogood/update_add/translations/zh_CN.all.json b/test_fixtures/fixup/notsogood/update_add/translations/all.zh_CN.json similarity index 100% rename from test_fixtures/fixup/notsogood/update_add/translations/zh_CN.all.json rename to test_fixtures/fixup/notsogood/update_add/translations/all.zh_CN.json diff --git a/test_fixtures/rewrite_package/init_code_snippet_filename/input_files/init_code_snippet.go.template b/test_fixtures/rewrite_package/init_code_snippet_filename/input_files/init_code_snippet.go.template index 4847420..a009d6d 100644 --- a/test_fixtures/rewrite_package/init_code_snippet_filename/input_files/init_code_snippet.go.template +++ b/test_fixtures/rewrite_package/init_code_snippet_filename/input_files/init_code_snippet.go.template @@ -4,7 +4,7 @@ import ( "fmt" "path/filepath" - i18n "github.com/maximilien/i18n4go/i18n4go/i18n" + "github.com/maximilien/i18n4go/i18n4go/i18n" ) var T i18n.TranslateFunc