Browse Source

feat: add Galician plural

Frédéric Guillot 1 month ago
parent
commit
8b84a86f0c
3 changed files with 13 additions and 0 deletions
  1. 1 0
      internal/locale/catalog_test.go
  2. 5 0
      internal/locale/plural.go
  3. 7 0
      internal/locale/plural_test.go

+ 1 - 0
internal/locale/catalog_test.go

@@ -105,6 +105,7 @@ func TestTranslationFilePluralForms(t *testing.T) {
 		"es_ES":            2,
 		"fi_FI":            2,
 		"fr_FR":            2,
+		"gl_ES":            2,
 		"hi_IN":            2,
 		"id_ID":            1,
 		"it_IT":            2,

+ 5 - 0
internal/locale/plural.go

@@ -31,6 +31,11 @@ func getPluralForm(lang string, n int) int {
 		default:
 			return 2
 		}
+	case "gl_ES":
+		if n != 1 {
+			return 1
+		}
+		return 0
 	case "id_ID", "ja_JP":
 		return 0
 	case "pl_PL":

+ 7 - 0
internal/locale/plural_test.go

@@ -44,6 +44,13 @@ func TestPluralRules(t *testing.T) {
 			2: 1, // n > 1
 			5: 1, // n > 1
 		},
+		// Galician (gl_ES) - n != 1
+		"gl_ES": {
+			0: 1, // n != 1
+			1: 0, // n == 1
+			2: 1, // n != 1
+			5: 1, // n != 1
+		},
 		// Indonesian (id_ID) - always form 0
 		"id_ID": {
 			0:   0,