PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, February 15, 2022

[FIXED] cakePHP 3.3 internationalization

 February 15, 2022     cakephp, cakephp-3.0     No comments   

Issue

How can I set multiple language in case text is in array?

I know that if I use this

<?= __('username')?>

and in directory /src/Locale/de_DE/default.po I have written following

msgid "username"
msgstr "benutzer"

It's gonna change username to benutzer if I set language to de_DE (german)


But what to do if I have this

<?= $this->Form->input('password',['label' =>'Password']); ?>

and I would like to change label Password


Solution

Simple:

$this->Form->input('password', ['label' => __('Password')]);

The __() function simply returns the translated string (more info). In your example you used

<?= ... ?>

which is equivalent to

<?php echo ... ?>


Answered By - JvO
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home
View mobile version

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing