Skip to content

Add language switching capability

Matthias Larisch requested to merge add-translatability into master

What does this MR do?

This restructures the project a bit to comply to standard symfony structure so we don't need to manually add translation, form and validation service. Then, we also follow the standard translation file name convention and add a second, very incomplete language file for english.

Frontend is modified to be able to use a second language with fallback as well.

A session variable is used to store the locale of a session which is then used to configure the right locale on each request.

The REST api does not yet follow the locale settings. Also, all "legacy" PHP translations do not follow this yet. My plan is to semi-automatically transfer all language strings into the yaml files and forward all translation requests to the symfony translator in a separate MR. Also I did not add any tests yet as I see this more as a proof of concept. As there is no official language switcher yet, if the page stays german and does not break it's fine :-)

How confident are you it won't break things if deployed?

quite confident, still, I am around.

Links to related issues

How to test

  1. Play around on the page: Everything should be german.

  2. Open localhost:18080/api/doc and do a get request on /api/locale. Watch the request in your browsers network tab and copy the CSRF token cookie value into the CSRF token authentication field on the top of the swagger page.

  3. Use the POST request to /api/locale/ to set the locale to en.

  4. See the menu partially translated (Vue.JS path) and the working group edit page partially translated (php symfony translator path)

Screenshots (if applicable)

Bildschirmfoto_von_2020-05-06_20-11-15

Checklist

  • added a test, or explain why one is not needed/possible...
  • no unrelated changes
  • asked someone for a code review
  • joined #foodsharing-beta channel at https://slackin.yunity.org
  • added an entry to CHANGELOG.md (description, merge request link, username(s))
  • Once your MR has been merged, you are responsible to update the #foodsharing-beta Slack channel about what has been changed here. They will test your work in different browsers, roles or other settings
Edited by Chris Oelmueller

Merge request reports