Languages

How to add new strings to language packs

 
Picture of Nicola Piccolo
How to add new strings to language packs
 

Hi all,
          I'm working on the latest Moodle 2.1 build and I couldn't gather enough information about how to add new strings to the Italian language pack (also English pack would be welcome).

These new strings are specific to my project (i.e. they're not already defined in native Moodle localization files) and I'd really like to isolate them in a specific file (e.g. my_web_site_strings.php) so I can better manage any kind of upgrade of Moodle or backup routines.

As far as I've read the docs online, I can surely customize the native Moodle strings, without any other tool to create new ones: am I right? If so, what's the recommended procedure to add new strings to a language pack? Please, use my case as example for the guideline (italian language AND english language).

Thank you in advance for your kind support,
best regards,
Nicola

 
Average of ratings: -
Tim at Lone Pine Koala Sanctuary
Re: How to add new strings to language packs
Core developersDocumentation writersParticularly helpful MoodlersPlugin developers

Create a new local plugin for this local/mystrings/lang/en/local_mystrings.php

Then you can refer to them using get_string('whatever', 'local_mystirings');

 
Average of ratings: Useful (2)
Picture of Nicola Piccolo
Re: How to add new strings to language packs
 

Thank you Tim,
                          I've found out the piece that I was looking for. I'll have a try!!!
Thank you again,
Nicola

 
Average of ratings: -
Picture of Albert Leatherman
Re: How to add new strings to language packs
 

On a sort-of related note, is it possible to insert language strings on pages we create? I'd like to insert some text using custom language strings I plan to create in several languages so that when a user changes the language of the site, the text I'm inserting also changes language. Thanks.


 
Average of ratings: -
Picture of David Mudrák
Re: How to add new strings to language packs
Core developersDocumentation writersMoodle HQParticularly helpful MoodlersPlugin developersPlugins guardiansTestersTranslators

is it possible to insert language strings on pages we create?

No, there is no such way I would be aware of.

when a user changes the language of the site, the text I'm inserting also changes language

For short text snippets, you can use Multi-language content filter. For anything longer I would suggest Restriction by language plugin as a better alternative (especially for resources).

 
Average of ratings: Useful (1)
Picture of Albert Leatherman
Re: How to add new strings to language packs
 

Thank you. Both those tools look very useful for what I am trying to accomplish.

 
Average of ratings: -