尊龙凯时人生就是博

laravelÔõô½«Ó¢ÎÄ·ûºÅתÖÐÎÄ·ûºÅ

Ëæ×Å»¥ÁªÍøµÄÉú³¤ £¬ÈËÃǵĽ»Á÷·½·¨Ò²Ô½À´Ô½¶àÔª»¯¡£ÔÚʹÓõç×ÓÓʼþ¡¢Î¢ÐÅ¡¢¶ÌÐŵȹ¤¾ß¾ÙÐÐÏàͬʱ £¬³£³£»á·ºÆðÓ¢ÎÄ·ûºÅ £¬Èç ¡°@¡±¡¢¡°#¡±¡¢¡°&¡±µÈ¡£È»¶ø £¬ÔÚʹÓÃÖÐÎľÙÐн»Á÷ʱ £¬Ó¢ÎÄ·ûºÅÍùÍù»á¸øÈË´øÀ´À§ÈÅ¡£ÌØÊâÊÇÔÚʹÓÃlaravelÕâÑùµÄ¿ª·¢¿ò¼Ü¾ÙÐбà³Ìʱ £¬Ó¢ÎÄ·ûºÅµÄ·ºÆð»áµ¼Ö´úÂëÄÑÒÔÔĶÁºÍÃ÷È·¡£Îª´Ë £¬laravelÌṩÁËÒ»ÖֺܺõĽâ¾ö¼Æ»®¡ª¡ªÓ¢ÎÄ·ûºÅתÖÐÎÄ·ûºÅ¡£

ÔÚLaravelÖÐ £¬¿ÉÒÔʹÓÃÒ»¸ö½Ð×ö¡°Laravel Localization¡±µÄ×é¼þÀ´ÊµÏÖÓ¢ÎÄ·ûºÅתÖÐÎÄ·ûºÅ¡£Localization£¨ÍâµØ»¯£©ÊÇÖ¸½«³ÌÐò˳Ӧ²î±ðÓïÑÔºÍÎÄ»¯ÇéÐεÄÀú³Ì¡£Í¨¹ýʹÓÃLaravel Localization £¬ÎÒÃÇ¿ÉÒÔ¼òÆӵؽ«Ó¢ÎÄ·ûºÅת»»ÎªÖÐÎÄ·ûºÅ £¬Ê¹µÃ³ÌÐòÔ½·¢Ò×ÓÚÔĶÁºÍÃ÷È·¡£

ÏÂÃæ £¬ÎÒÃÇÀ´¿´Ò»ÏÂÔõÑùʹÓÃLaravel Localization¾ÙÐÐÓ¢ÎÄ·ûºÅµ½ÖÐÎÄ·ûºÅµÄת»»¡£

Ê×ÏÈ £¬ÎÒÃÇÐèҪװÖÃLaravel Localization¡ £¿ÉÒÔͨ¹ýComposerÀ´×°Öãº

composer require mcamara/laravel-localization

µÇ¼ºó¸´ÖÆ

È»ºó £¬ÎÒÃÇÐèÒªÔÚ config/app.php ÖÐ×¢²áServiceProvider£º

'providers' => [
    // ...
    Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider::class,
];

µÇ¼ºó¸´ÖÆ

½Ó×Å £¬ÔÚ config/app.php ÖÐ×¢²áFacades£º

'aliases' => [
    // ...
    'LaravelLocalization' => Mcamara\LaravelLocalization\Facades\LaravelLocalization::class,
];

µÇ¼ºó¸´ÖÆ

ÏÖÔÚ £¬ÎÒÃÇ¿ÉÒÔÔÚ routes.php ÎļþÖнç˵ËùÓÐÖ§³ÖµÄÓïÑÔ£º

Route::group([
    'prefix' => LaravelLocalization::setLocale()], function () {
         // ...
});

µÇ¼ºó¸´ÖÆ

ÔÚ½ç˵ÓïÑÔºó £¬ÎÒÃÇÐèÒª½ç˵ÓïÑÔÎļþ £¬¸ÃÎļþÉúÑÄÁËËùÓеÄÓ¢ÎÄ·ûºÅÒÔ¼°¶ÔÓ¦µÄÖÐÎÄ·ûºÅ¡£ÔÚLaravel LocalizationÖÐ £¬ÓïÑÔÎļþͨ³£´æ´¢ÔÚ resources/lang Ŀ¼Ï £¬ÃüÃûΪ en.php£¨Ó¢ÎÄ£©ºÍ cn.php£¨ÖÐÎÄ£©¡£

ÒÔʹÓõÄÓïÑÔΪÖÐÎÄΪÀý £¬ÎÒÃÇÔÚ cn.php ÖÐÌí¼ÓÒÔÏÂÄÚÈÝ£º

return [
    '@' => '£À', 
    '#' => '££', 
    '&' => '£¦', 
    // ...
];

µÇ¼ºó¸´ÖÆ

ͨ¹ýÒÔÉϽç˵ £¬ÎÒÃǽ« @ ·ûºÅת»»Îª £À ·ûºÅ £¬# ·ûºÅת»»Îª ££ ·ûºÅ £¬& ·ûºÅת»»Îª £¦ ·ûºÅ £¬ÒÀ´ËÀàÍÆ¡£

×îºó £¬ÎÒÃÇÐèÒªÔÚ´úÂëÖÐʹÓà trans º¯Êý¾ÙÐзûºÅµÄת»»¡£ÀýÈç £¬ÎÒÃÇʹÓà trans º¯Êý½« @ ·ûºÅת»»Îª £À ·ûºÅ£º

$email = 'example@mail.com';
$converted_email = trans($email, ['@' => '£À']);
echo $converted_email; // ½«Êä³ö example£Àmail.com

µÇ¼ºó¸´ÖÆ

ͨ¹ýÕâ¸öÀý×Ó £¬ÎÒÃÇ¿ÉÒÔ¿´µ½ £¬Laravel LocalizationÌṩÁËÒ»ÖÖ¼òÆÓÇÒÒ×ÓÚ²Ù×÷µÄÒªÁì £¬Äܹ»ºÜºÃµØ½â¾öÓ¢ÎÄ·ûºÅÔÚʹÓÃÖÐÎľÙÐн»Á÷ʱµÄÎÊÌâ¡£

×ܽáÀ´Ëµ £¬Laravel LocalizationÄܹ»×ÊÖúÎÒÃÇÔÚʹÓÃLaravel¿ò¼Ü¾ÙÐбà³Ìʱ¾ÙÐÐÓ¢ÎÄ·ûºÅµ½ÖÐÎÄ·ûºÅµÄת»»¡£ÕâÑù £¬ÎÒÃǾÍÄܹ»×èÖ¹Ó¢ÎÄ·ûºÅ´øÀ´µÄÀ§ÈÅ £¬ÈóÌÐòÔ½·¢Ò×ÓÚÔĶÁºÍÃ÷È·¡£

ÒÔÉϾÍÊÇlaravelÔõô½«Ó¢ÎÄ·ûºÅתÖÐÎÄ·ûºÅµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是博ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是博ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是博

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ