getherbert / herbert

The WordPress Plugin Framework:
http://getherbert.com/
632 stars 94 forks source link

Using .po .mo files #100

Closed imboden closed 8 years ago

imboden commented 8 years ago

Hello Team,

I try to rebuild an old plugin with Herbert.

I have imported the old folder /languages

I'm trying __( and _e( in controller such as explained there: https://github.com/getherbert/herbert/issues/70

but nothing is working I never got the translations.

Any idea why? Should I use a special "use" or "import/include" or "route"? where should I put the .po .mo files?

Thanks

David

onnimonni commented 8 years ago

I added translations like this in one project.

plugin.php:

<?php

/**
 * @wordpress-plugin
 * Plugin Name:       Example plugin
 * Plugin URI:        http://plugin-name.com/
 * Description:       Plugin description
 * Version:           1.0
 * Author:            Me
 * Author URI:        http://author.com/
 * License:           MIT
 * Domain Path: /languages
 */

/*
 * Translations
 */
add_action( 'plugins_loaded', 'my_herbert_plugin_load_textdomain' );
function my_herbert_plugin_load_textdomain() {
  load_plugin_textdomain( 'my-text-domain', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
}

require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/vendor/getherbert/framework/bootstrap/autoload.php';

and put *.mo and *.po files in languages folder in your project.

This might not be the real herbert way but it works.

onnimonni commented 8 years ago

Closing in favor of #70