Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
erikyo committed Dec 17, 2023
1 parent f875012 commit 71c32b6
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/ISOToLanguage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ function format(
// Step 3: Try to get country from language if country is not provided
if (!country) {
const countries = getCountriesByLanguage([language.toLowerCase()])
country = Object.keys(countries)[0]
const countriesKeys = Object.keys(countries)
if (countriesKeys.length === 1) {
country = countriesKeys[0]
}
}

// Return the formatted string if both language and country are found
Expand Down Expand Up @@ -134,10 +137,9 @@ function getAllCountryLanguage(separator: string = '_'): string[] {
for (const iso in isoList) {
for (const language of isoList[iso as ISOCode].languages) {
const languageCode = format(language, iso, { separator })
if (!languageCode) {
continue
if (languageCode) {
languageCodes[languageCode] = true
}
languageCodes[languageCode] = true
}
}
return Object.keys(languageCodes)
Expand Down Expand Up @@ -286,7 +288,7 @@ function useKey(
iso: ISOCode | string,
countryData: Country,
type?: 'locale' | 'language-code'
): { [key: string]: CountryData } {
): Record<string, CountryData> {
const result: { [key: string]: CountryData } = {}
// Get the separator based on the type
const separator = getSeparator( type )
Expand Down

0 comments on commit 71c32b6

Please sign in to comment.