matalve / flagfilter

Flagfilter is a quick and easy to use site for finding what flag you are looking for. Search for name, color, pattern or a combination.
http://flagfilter.com
GNU General Public License v3.0
0 stars 0 forks source link

Translate flag information and tags to other languages #53

Open matalve opened 1 year ago

matalve commented 1 year ago

This requires:

  1. Using a Translation service, I guess crowdsourced
  2. Uploading terms to translation service
  3. Getting people to translate the terms - Spanish preferred focus.
  4. Downloading and converting translated terms to something the page can read
  5. Language picker on site (prefer not to use different domains)
matalve commented 1 year ago

I've registered the project with an Open source license at POEditor to solve bullet 1: https://poeditor.com/join/project/P7N0JxV3wI Need to add link to page footer as well.

matalve commented 1 year ago

Added the terms and English translation with this Powershell script (solving bullet 2):

$urlBase = "https://api.poeditor.com/v2/"
$Method = "POST"
$Header = @{"Content-Type" = "application/x-www-form-urlencoded"}
$apiToken = "<tokenhex>"
$projectID = "654073"

$jsonInput = Get-Content 'C:\<path>\flagfilter\flaginfo.json' | Out-String | ConvertFrom-Json

foreach ($flag in $jsonInput) {
    $termTags = $flag.shortname + "_tags"
    $termName = $flag.shortname + "_name"
    $termSymbolism = $flag.shortname + "_symbolism"
    $termFunfacts = $flag.shortname + "_funfacts"
    $tags = $flag.tags -replace "flagobject ", ""

    $jsonArrayTerms = @(@{ "term" = $termTags }, @{ "term" = $termName }, @{ "term" = $termSymbolism }, @{ "term" = $termFunfacts }) | ConvertTo-Json -Compress

    $Body = @{
        api_token = $apiToken
        id = $projectID
        data = $jsonArrayTerms
    }

    $uri = $urlBase + "terms/add"
    Invoke-WebRequest -Uri $uri -Method $Method -Headers $Header -Body $Body

    Start-Sleep -Milliseconds 400

    $translationTags = @{ "content" = $tags}
    $translationName = @{ "content" = $flag.name}
    $translationSymbolism = @{ "content" = $flag.symbolism}
    $translationFunfacts = @{ "content" = $flag.funfacts}

    $jsonArrayTranslate = @(@{ "term" = $termTags; "translation" = $translationTags }, @{ "term" = $termName; "translation" = $translationName }, @{ "term" = $termSymbolism; "translation" = $translationSymbolism }, @{ "term" = $termFunfacts; "translation" = $translationFunfacts }) | ConvertTo-Json -Compress

    $Body = @{
        api_token = $apiToken
        id = $projectID
        language = "en"
        data = $jsonArrayTranslate
    }

    $uri = $urlBase + "translations/add"
    Invoke-WebRequest -Uri $uri -Method $Method -Headers $Header -Body $Body

    Start-Sleep -Milliseconds 400
}