Skip to content

Commit

Permalink
Merge pull request #75 from razor-1/new-langs
Browse files Browse the repository at this point in the history
Bolivian Quechua Portuguese and Brazilian Sign Language
  • Loading branch information
razor-1 authored Jan 2, 2025
2 parents 54b9709 + 3e37d4f commit ae050d0
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
9 changes: 7 additions & 2 deletions locale.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ package localizer

import (
"fmt"
cldr "github.com/razor-1/localizer-cldr"
"regexp"
"strings"
"sync"

cldr "github.com/razor-1/localizer-cldr"

"github.com/razor-1/localizer-cldr/resources"
"golang.org/x/text/language"
"golang.org/x/text/message"
Expand Down Expand Up @@ -137,7 +138,7 @@ func getFallbackTag(tag language.Tag) (language.Tag, error) {
return language.English, nil
case "ca-valencia":
return language.Catalan, nil
case "quc":
case "quc", "quh":
return language.LatinAmericanSpanish, nil
case "lir":
return language.English, nil
Expand All @@ -147,6 +148,10 @@ func getFallbackTag(tag language.Tag) (language.Tag, error) {
return language.Make("ee"), nil
case "tw":
return language.Make("ak"), nil
case "psr":
return language.EuropeanPortuguese, nil
case "bzs":
return language.BrazilianPortuguese, nil
}

return language.Tag{}, fmt.Errorf("no fallback for tag %s", tag.String())
Expand Down
21 changes: 21 additions & 0 deletions locale_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,25 @@ func TestGetLocaleData(t *testing.T) {
l, err = localizer.GetLocaleData(tag)
ta.NoError(err)
ta.Equal("ak", language.MustParse(l.Locale).String())

tag, err = language.Parse("quh")
ta.NoError(err)
ta.Equal("quh", tag.String())
l, err = localizer.GetLocaleData(tag)
ta.NoError(err)
ta.Equal(language.LatinAmericanSpanish, language.MustParse(l.Locale))

tag, err = language.Parse("psr")
ta.NoError(err)
ta.Equal("psr", tag.String())
l, err = localizer.GetLocaleData(tag)
ta.NoError(err)
ta.Equal(language.EuropeanPortuguese, language.MustParse(l.Locale))

tag, err = language.Parse("bzs")
ta.NoError(err)
ta.Equal("bzs", tag.String())
l, err = localizer.GetLocaleData(tag)
ta.NoError(err)
ta.Equal(language.BrazilianPortuguese, language.MustParse(l.Locale))
}

0 comments on commit ae050d0

Please sign in to comment.