Gossamer Forum
Home : Products : Gossamer Forum : Development, Plugins and Globals :

Re: [Jagerman] Language vars

Quote Reply
Re: [Jagerman] Language vars
Sorry for slightly changing topics, but:

what's the best way to write something into the language files in the install routine of a plugin?

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Quote Reply
Re: [yogi] Language vars In reply to
Here's the code used to get a language variable (from GForum/Tools.pm):

Code:
my $language = GT::Config->load("$dir/$file", { create_ok => 1, inheritance => 0, local => 0, debug => $CFG->{debug_level}, header => <<HEADER });
# This file is auto-generated and contains a perl hash of your
# language variables for the '$selected_dir' template set.
# Generated: [localtime]
# vim:syn=perl:ts=4HEADER


$dir/$file should be the path to the language file (typically, admin/templates/default/language.txt).

Note that this differs from GForum/Tools.pm in one important way - in GForum/Tools.pm, it has the local and inheritance options set to 1. "local" makes it save in templates/template_set/local/language.txt, and "inheritance" makes it load any inherited template set data into the object, but since you don't care about reading from this language file, and since you really don't want to save into "local", both of those options should be off.

Then you set your language variables with something like:

Code:
$language->{MY_LANGUAGE_VARIABLE} = "This is my language variable.";


Finally, save the language file back to disk with:

Code:


$language->save();

Jason Rhinelander
Gossamer Threads
jason@gossamer-threads.com