Jump to content

Custom getText (a temporary fix)


turbotutone

Recommended Posts

Hello,

 

Yesterday i posed a question in the Modding Help section about using custom translations.

http://theindiestone.com/forums/index.php/topic/3676-custom-texts-for-gettext/

 

Conclusion, it is not possible yet to use a translations .txt as found in the game already, but theres a option comming available soon.

 

Now i wanted to see if i could use getText in my lua files already instead of strings so i dont have to replace them later on when this option comes available. But since a option is coming available soon i wanted to keep it simple and make it so that when the official method comes around i could easily copy paste my translation data.

 

So the result is a very simple getText override:

--***********************************************************--**                    TURBOTUTONE                        **--**       Temporary custom translations fix               **--***********************************************************-- set the language you want to test herelangBrev = 'EN';-- improvised translation tabletLang = {};-- English language sectiontLang['EN'] = {	-- Custom context menu stuff:	CtxTurboCraft_Build = "TurboCraft build",	-- Add more stuff:}-- saving the original getText functionlocal old_getText = getText;-- simple getText overridegetText = function(string)	-- check the offical translation function	local str = old_getText(string);		-- if the strings dont match its safe to assume an official translation has been found, we return	if str ~= string then 		return str; 	end		-- if the strings matched previously, were gonna check the improvised translation table	if tLang[langBrev][string] ~= nil then		return tLang[langBrev][string];	end		-- if none found, return the string as is	return string;end

Copy paste the code to a lua file in your mod directory and add your custom translations to the translation table (tLang) and it should work the same as with the official translation, for example:

getText("CtxTurboCraft_Build")

Now when there comes a official method for modders available to do custom languages, then you should be able to simply copy the translation data between the brackets of the tLang table into the appropiate text file formatting and remove this temporary fix lua file.

 

Regards,

Turbo

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...