setlanguage.php 608 B

12345678910111213141516171819202122
  1. <?php
  2. $l=OC_L10N::get('settings');
  3. OC_JSON::checkLoggedIn();
  4. OCP\JSON::callCheck();
  5. // Get data
  6. if( isset( $_POST['lang'] ) ) {
  7. $languageCodes=OC_L10N::findAvailableLanguages();
  8. $lang=$_POST['lang'];
  9. if(array_search($lang, $languageCodes) or $lang=='en') {
  10. OC_Preferences::setValue( OC_User::getUser(), 'core', 'lang', $lang );
  11. OC_JSON::success(array("data" => array( "message" => $l->t("Language changed") )));
  12. }else{
  13. OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
  14. }
  15. }else{
  16. OC_JSON::error(array("data" => array( "message" => $l->t("Invalid request") )));
  17. }