setlanguage.php 659 B

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