PiPass / blockpage

A temporary unblock solution and blockpage for your Pi-Hole system
BSD 3-Clause "New" or "Revised" License
196 stars 14 forks source link

Locales beta - Get language from the end-user's browser. #30

Closed JoeSchubert closed 5 years ago

JoeSchubert commented 5 years ago

I like the idea here, translations should definitely be a thing.

This should scan all of the locale-xx.php files in the locales folder, add them to an array and select the desired language based on what the end-user has set up in their browser. If there's no matching translation, default to the one that was specified in the configuration.

The format will have to be ISO-639-1 for the 2 letter codes, see here: https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes

This default locale file WILL have to exist and there are currently no checks to ensure that. We could protect against that, but at what point are we just protecting people from themselves.

roenw commented 5 years ago

Doesn't seem to be working for me. It's requiring the file ../locale/locale-.php which means the getLanguage() function isn't working. I'll try to have a look and try to fix it later.

JoeSchubert commented 5 years ago

Ah. Weird, maybe I messed up something prior to committing. Been pretty busy. I'll look at it in just a little bit.

JoeSchubert commented 5 years ago

@roenw maybe this will help? Not really sure how to get it to work right... PHP isn't really something I'm great with. But I'm testing it using this test file, with some index-xx.php files in a locales folder with the test file. I've changed the function a little so that you have to pass the configured language and the preferred language. I'm sure that it's something with variable scopes or something.

https://gist.github.com/yoinx/c1d6110ee2805111a7dd726d5ceb2842

roenw commented 5 years ago

@yoinx I'll try to test this tomorrow

JoeSchubert commented 5 years ago

@roenw any luck with this?

roenw commented 5 years ago

At some point I’ll try and make it work, but I don’t think it’ll be in this release.

Sent from my iPhone

On Jun 15, 2019, at 3:02 AM, Joe Schubert notifications@github.com wrote:

@roenw any luck with this?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

roenw commented 5 years ago

I’ll find a better way to do this later. Tabled for a future update.