I have made a custom 'Account Creation' script so that users can login from my phone application.
What I want is to be able to change the responses from the server depending on their locale. So when I request a page I would add lang=en or lang=zh etc.
This works
http://mysite.com/phone/my_custom_account_creation.php?lang=en
Response:
<resource classification="error" code="Error (Code: 500)">
<message>Please enter your name:</message>
</resource>
This does not work:
http://mysite.com/phone/my_custom_account_creation.php?lang=zh
Response:
<resource classification="error" code="Error (Code: 500)">
<message>Please enter your name:</message>
</resource>
If I go into Joomla at set the default language to chinese, it works.
<resource classification="error" code="Error (Code: 500)">
<message>请输入您的姓名。</message>
</resource>
but
http://mysite.com/phone/my_custom_account_creation.php?lang=en does not work, instead it continues to show the chinese version.
What might I be able to do here?
here is the code I am using for registration:
<?php
header ("content-type: text/xml");
/*
* Register a user from a phone interface using JAVA
*/
define( '_JEXEC', 1 );
//define('JPATH_BASE', dirname(__FILE__) );//this is when we are in the root
define('JPATH_BASE', dirname(__FILE__)."/../.." );//this is when we are in the root
define( 'DS', DIRECTORY_SEPARATOR );
require_once ( JPATH_BASE .DS.'includes'.DS.'defines.php' );
require_once ( JPATH_BASE .DS.'includes'.DS.'framework.php' );
//My functions
require_once('../shared_functions.php');
$mainframe =& JFactory::getApplication('site');
$mainframe->initialise();
//Don't use tokens for registration
//JRequest::checkToken() or jexit( 'Invalid Token' );
$user = clone(JFactory::getUser());
$pathway = & $mainframe->getPathway();
$config = & JFactory::getConfig();
$authorize = & JFactory::getACL();
$document = & JFactory::getDocument();
$usersConfig = &JComponentHelper::getParams( 'com_users' );
if ($usersConfig->get('allowUserRegistration') == '0')
{
xmlError("Access Forbidden (Code 403)","Registration has been temporarily disabled");
//JError::raiseError( 403, JText::_( 'Access Forbidden' ));
return;
}
$newUsertype = $usersConfig->get( 'new_usertype' );
if (!$newUsertype)
{
$newUsertype = 'Registered';
}
if (!$user->bind( JRequest::get('post'), 'usertype' ))
{
xmlError("Error (Code: 500)",$user->getError());
return;
//JError::raiseError( 500, $user->getError());
}
$user->set('id', 0);
$user->set('usertype', '');
$user->set('gid', $authorize->get_group_id( '', $newUsertype, 'ARO' ));
$date =& JFactory::getDate();
$user->set('registerDate', $date->toMySQL());
$useractivation = $usersConfig->get( 'useractivation' );
if ($useractivation == '1')
{
jimport('joomla.user.helper');
$user->set('activation', md5( JUserHelper::genRandomPassword()) );
$user->set('block', '1');
}
if (!$user->save()) { // if the user is NOT saved...
xmlError("Error (Code: 500)",$user->getError());
//JError::raiseWarning('', JText::_( $user->getError())); // ...raise an Warning
//return false; // if you're in a method/function return false
}
xmlMessage("ok",CODE_ACCOUNT_CREATED,"Success");
?>