Merge branch 'master' into develop

This commit is contained in:
Taylor Otwell 2013-01-05 14:36:48 -06:00
commit 875cac6c83
3 changed files with 28 additions and 4 deletions

View File

@ -11,7 +11,7 @@ ## The Basics
Localization is the process of translating your application into different languages. The **Lang** class provides a simple mechanism to help you organize and retrieve the text of your multilingual application.
All of the language files for your application live under the **application/language** directory. Within the **application/language** directory, you should create a directory for each language your application speaks. So, for example, if your application speaks English and Spanish, you might create **en** and **sp** directories under the **language** directory.
All of the language files for your application live under the **application/language** directory. Within the **application/language** directory, you should create a directory for each language your application speaks. So, for example, if your application speaks English and Spanish, you might create **en** and **es** directories under the **language** directory.
Each language directory may contain many different language files. Each language file is simply an array of string values in that language. In fact, language files are structured identically to configuration files. For example, within the **application/language/en** directory, you could create a **marketing.php** file that looks like this:
@ -23,7 +23,7 @@ #### Creating a language file:
);
Next, you should create a corresponding **marketing.php** file within the **application/language/sp** directory. The file would look something like this:
Next, you should create a corresponding **marketing.php** file within the **application/language/es** directory. The file would look something like this:
return array(
@ -50,7 +50,7 @@ #### Retrieving a language line using the "__" helper:
#### Getting a language line in a given language:
echo Lang::line('marketing.welcome')->get('sp');
echo Lang::line('marketing.welcome')->get('es');
<a name="replace"></a>
## Place Holders & Replacements

View File

@ -62,6 +62,10 @@ #### Returning a JSON response:
return Response::json(array('name' => 'Batman'));
#### Returning a JSONP response:
return Response::jsonp('myCallback', array('name' => 'Batman'));
#### Returning Eloquent models as JSON:
return Response::eloquent(User::find(1));

View File

@ -100,6 +100,26 @@ public static function json($data, $status = 200, $headers = array(), $json_opti
}
/**
* Create a new JSONP response.
*
* <code>
* // Create a response instance with JSONP
* return Response::jsonp('myFunctionCall', $data, 200, array('header' => 'value'));
* </code>
*
* @param mixed $data
* @param int $status
* @param array $headers
* @return Response
*/
public static function jsonp($callback, $data, $status = 200, $headers = array())
{
$headers['Content-Type'] = 'application/javascript; charset=utf-8';
return new static($callback.'('.json_encode($data).');', $status, $headers);
}
/**
* Create a new response of JSON'd Eloquent models.
*
@ -346,4 +366,4 @@ public function __toString()
return $this->render();
}
}
}