Localize proxy test info when possible (#4255)

* Localize proxy test info when possible

* Use a second find in-case a locale with the same language is added in the future

Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>

* Fix syntax error

Co-authored-by: PikachuEXE <pikachuexe@gmail.com>

---------

Co-authored-by: Jason <84899178+jasonhenriquez@users.noreply.github.com>
Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
This commit is contained in:
ChunkyProgrammer 2023-10-31 13:07:42 -04:00 committed by GitHub
parent a6cdd4b1b1
commit 7304d75239
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 1 deletions

View File

@ -29,7 +29,6 @@ export default defineComponent({
return {
isLoading: false,
dataAvailable: false,
proxyTestUrl: 'https://ipwho.is/?output=json&fields=ip,country,city,region',
proxyIp: '',
proxyCountry: '',
proxyRegion: '',
@ -64,6 +63,22 @@ export default defineComponent({
},
proxyUrl: function () {
return `${this.proxyProtocol}://${this.proxyHostname}:${this.proxyPort}`
},
lang: function() {
return this.$i18n.locale.replace('_', '-')
},
localeToUse: function() {
// locales found here: https://ipwhois.io/documentation
const supportedLangs = ['en', 'ru', 'de', 'es', 'pt-BR', 'fr', 'zh-CN', 'ja']
return supportedLangs.find(lang => this.lang === lang) ?? supportedLangs.find(lang => this.lang.substring(0, 2) === lang.substring(0, 2))
},
proxyTestUrl: function() {
let proxyTestUrl = 'https://ipwho.is/?output=json&fields=ip,country,city,region'
if (this.localeToUse) {
proxyTestUrl += `&lang=${this.localeToUse}`
}
return proxyTestUrl
}
},
created: function () {