CalderaWP / metaplate-core

Front-end for Calera Metaplate, Handlebars.php-based custom field templating and display system.
GNU General Public License v2.0
3 stars 1 forks source link

.php file type to allow dynamic rendering for translations #3

Open DavidCramer opened 9 years ago

DavidCramer commented 9 years ago

having .html or .htm is all very well, but wont be easily translated. having php on an include will allow to do things like :

{{#if rates}}
<h2><?php _e( Rate', 'theme-slug' ); ?></h2>
{{/if}}
Shelob9 commented 9 years ago

Yes but then we need eval(), not very secure.

On Sat, Apr 25, 2015, 7:09 AM David Cramer notifications@github.com wrote:

having .html or .htm is all very well, but wont be easily translated. having php on an include will allow to do things like :

{{#if rates}}

{{/if}}

— Reply to this email directly or view it on GitHub https://github.com/CalderaWP/metaplate-core/issues/3.

Shelob9 commented 9 years ago

Here's my proposal:

Then you could do:

            $strings = array(
                'happy' => __( 'Happiness, woo!', 'slug' ),
                'cats' => __( 'Cats', 'slug' ),
            );
            caldera_metaplate_localize( 'metaplate_id', $strings );

Not sure where you do that..., but then in the metaplate you do:

{{#translatable_string happy}}