setlanguage.php 640 B

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