the AddLanguageFileKey is actually a contrib package action (from http://packageactioncontrib.codeplex.com) I am not sure of the status of that in Umbraco 7, but the language file format hasn't changed in a while, so if it runs it should add the values for you.
from Umbraco 7.3 the language files can live in the property type folder - so the code in the posts above merges that file if it's pre v7.3 - only real advantage is that you don't have to fiddle with the package.xml every time you change a language thing.
Hi,
No my idea didnt work - it didnt update the Lang files :(.
When you mention create a Class in your above comment where would I create that class - in a seperate project dll? and then include that dll in my Package?
Yes i would build the class into a dll and include it in the package. as long as it impliments IPacakgeAction you should be able to call it, that's how the OpeningSoon package does it.
Amazing help - many thanks - I followed your instructions and looked at what you did in Opening Soon and it was as easy as you say - Create a new project to create your DLL and then call it in the Package.xml file.
Make sure you have your Lang folder in the Plugin folder with your new language keys and Bob's your uncle :)
Thanks again,
Jon
Create Package Action to update Lang Files
Hi, I have created a Package and my HTML file has a few Labels that I would like to use the Lang XML files to store the Text. How do I create a C# class which runs on Install so the users Lang.xml files are up to date? I have looked at https://our.umbraco.org/forum/umbraco-7/developing-umbraco-7-packages/46770-Creating-new-Sections-Can-we-auto-generate-dictionary-item but it doesnt say where I should create this code and how I can Implement my new label text. Thanks Jon
Hi,
If you create a class that inherits
IPackageAction
, you can then call that from the actions section of your package.This is something I have done for the OpeningSoon package (https://github.com/KevinJump/OpeningSoon/blob/master/OpeningSoonInstaller/OpeningSoonPackageActions.cs)
This package action class calls a translation helper, which is heavily lifted from I lifted it from Articulate and Marchello but merges lang.xml files (https://github.com/KevinJump/OpeningSoon/blob/master/OpeningSoonInstaller/TranslationHelper.cs)
once you have something you can just add it to the actions section of the package (either in umbraco or the package.xml file)
Hi, Thanks for this.
I had another investigate and found something like this to add in the Actions section of the Create a Package:
undo="true " alias="AddLanguageFileKey" language="en " position="end" area="template" key="demo" value="This is a demo string" />
Would this work if all I had were a few updates?
yeah that might work,
the AddLanguageFileKey is actually a contrib package action (from http://packageactioncontrib.codeplex.com) I am not sure of the status of that in Umbraco 7, but the language file format hasn't changed in a while, so if it runs it should add the values for you.
from Umbraco 7.3 the language files can live in the property type folder - so the code in the posts above merges that file if it's pre v7.3 - only real advantage is that you don't have to fiddle with the package.xml every time you change a language thing.
Hi, No my idea didnt work - it didnt update the Lang files :(. When you mention create a Class in your above comment where would I create that class - in a seperate project dll? and then include that dll in my Package?
Yes i would build the class into a dll and include it in the package. as long as it impliments IPacakgeAction you should be able to call it, that's how the OpeningSoon package does it.
Amazing help - many thanks - I followed your instructions and looked at what you did in Opening Soon and it was as easy as you say - Create a new project to create your DLL and then call it in the Package.xml file. Make sure you have your Lang folder in the Plugin folder with your new language keys and Bob's your uncle :) Thanks again, Jon
is working on a reply...