Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Plugin Developers: Hook Requests
#33
ccagle8 Wrote:
Zegnåt Wrote:I feel like we will need a way to have language files per plugin. We can come up with good ways to extend $il8n but people that want it in their own language will still need to dive into the core plugin code to change the strings…
not if the plugin developers include a language file with their plugin.

The I18N plugin already includes its own language files exactly like GetSimple itself, however, the strings are added with the plugin name as prefix:

Code:
i18n_add_texts($i18n);

function i18n_add_texts(&$globali18n) {
  global $LANG;
  $i18n = array();
  @include(GSPLUGINPATH.'i18n/lang/'.$LANG.'.php');
  if (count($i18n) == 0) @include(GSPLUGINPATH.'i18n/lang/en_US.php');
  foreach ($i18n as $code => $text) $globali18n['i18n/'.$code] = $text;
}

I suppose a similar functionality could be implemented in a core function:

Code:
function add_texts($directory, $prefix) {
  global $i18n, $LANG;
  call _add_texts($i18n, $LANG, $directory, $prefix);
}

// needed to avoid name clash between global and local $i18n - or save global one before
function _add_texts(&$globali18n, $LANG, $directory, $prefix) {
  $i18n = array();
  @include(GSPLUGINPATH.$directory.'/'.$LANG.'.php');
  if (count($i18n) == 0) @include(GSPLUGINPATH.$directory.'/en_US.php');
  foreach ($i18n as $code => $text) $globali18n[$prefix.'/'.$code] = $text;
}
I18N, I18N Search, I18N Gallery, I18N Special Pages - essential plugins for multi-language sites.
Reply


Messages In This Thread
Plugin Developers: Hook Requests - by ccagle8 - 2010-01-18, 13:45:08
RE: Plugin Developers: Hook Requests - by shawn_a - 2015-10-18, 09:19:33
Plugin Developers: Hook Requests - by Nijikokun - 2010-01-18, 14:49:02
Plugin Developers: Hook Requests - by ccagle8 - 2010-01-19, 00:00:30
Plugin Developers: Hook Requests - by n00dles101 - 2010-01-19, 04:27:04
Plugin Developers: Hook Requests - by internet54 - 2010-01-19, 05:59:48
Plugin Developers: Hook Requests - by ccagle8 - 2010-01-19, 06:36:23
Plugin Developers: Hook Requests - by Nijikokun - 2010-01-19, 08:56:53
Plugin Developers: Hook Requests - by n00dles101 - 2010-01-19, 09:01:56
Plugin Developers: Hook Requests - by ccagle8 - 2010-01-19, 09:53:09
Plugin Developers: Hook Requests - by Nijikokun - 2010-01-19, 09:58:25
Plugin Developers: Hook Requests - by n00dles101 - 2010-01-19, 10:03:17
Plugin Developers: Hook Requests - by oToom - 2010-01-20, 02:50:10
Plugin Developers: Hook Requests - by n00dles101 - 2010-01-20, 03:00:07
Plugin Developers: Hook Requests - by internet54 - 2010-01-20, 07:31:01
Plugin Developers: Hook Requests - by n00dles101 - 2010-01-20, 07:39:25
Plugin Developers: Hook Requests - by Nijikokun - 2010-01-21, 11:05:30
Plugin Developers: Hook Requests - by Sanddorn - 2010-02-22, 07:19:33
Plugin Developers: Hook Requests - by JWH_Matthew - 2010-02-22, 12:34:58
Plugin Developers: Hook Requests - by ccagle8 - 2010-02-22, 13:12:23
Plugin Developers: Hook Requests - by crashfellow - 2010-03-07, 17:04:49
Plugin Developers: Hook Requests - by ccagle8 - 2010-03-07, 23:28:35
Plugin Developers: Hook Requests - by ccagle8 - 2010-03-08, 01:09:07
Plugin Developers: Hook Requests - by superyms - 2010-03-08, 02:11:49
Plugin Developers: Hook Requests - by SamWM - 2010-05-15, 06:19:06
Plugin Developers: Hook Requests - by RobA - 2010-11-19, 08:27:37
Plugin Developers: Hook Requests - by RobA - 2010-11-23, 03:44:51
Plugin Developers: Hook Requests - by mvlcek - 2011-01-25, 07:05:41
Plugin Developers: Hook Requests - by mvlcek - 2011-01-25, 07:08:03
Plugin Developers: Hook Requests - by mvlcek - 2011-01-25, 07:13:24
Plugin Developers: Hook Requests - by Actimele - 2011-03-15, 15:54:17
Plugin Developers: Hook Requests - by RobA - 2011-04-22, 09:12:08
Plugin Developers: Hook Requests - by Connie - 2011-04-22, 15:26:55
Plugin Developers: Hook Requests - by Carlos - 2011-04-23, 01:38:00
Plugin Developers: Hook Requests - by RobA - 2011-04-23, 01:43:07
Plugin Developers: Hook Requests - by Carlos - 2011-04-23, 02:18:22
Plugin Developers: Hook Requests - by schoschie - 2011-06-25, 08:39:45
Plugin Developers: Hook Requests - by dominionit - 2011-07-15, 15:02:00
Plugin Developers: Hook Requests - by ccagle8 - 2011-07-17, 11:44:42
Plugin Developers: Hook Requests - by dominionit - 2011-07-17, 18:17:03
Plugin Developers: Hook Requests - by dominionit - 2011-07-18, 06:33:30



Users browsing this thread: 1 Guest(s)