It is currently September 16th, 2019, 11:46 am

Can I change the contents of skin depending on the language?

General topics related to Rainmeter.
oioo
Posts: 1
Joined: May 17th, 2019, 1:23 pm

Can I change the contents of skin depending on the language?

oioo » May 17th, 2019, 1:38 pm

Hey :)
I am currently working on a rainmeter skin, which displays some Information about the User, LogonServer, OS-Language, Computername usw.
To get the language I am using this:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
ActLangFile=#CURRENTPATH#ActLang

[MeasureRun]
Measure=Plugin
Plugin=RunCommand
Program=Powershell.exe
Parameter=-NoProfile -ExecutionPolicy Bypass -Command "((get-culture).Displayname)"
OutputType=ANSI
UpdateDivider=-1
OutputFile=#ActLangFile#
[MeasureLangFile]
Measure=Script
ScriptFile=#CURRENTPATH#LuaTextFile.lua
FileToRead=#ActLangFile#
RegExpSubstitution=1



[MeasureLang]
Measure=String
String=MeasureLangFile
Depending on the language (in my case english, german or french) I want to display the whole skin in the used language.

Does someone have an idea how I could do this? I was thinking about using .inc files which would contain the variables in the needed language.
Would this work or does anyone have an idea?
The .lua script which is used to read the file looks like this:

Code: Select all

function Initialize()

	sFileToRead = SELF:GetOption('FileToRead')
	
end

function Update()

	hReadingFile = io.open(sFileToRead)
	if not hReadingFile then
		print('LuaTextFile: unable to open file at ' .. sFileToRead)
		return
	end
	
	sAllText = hReadingFile:read("*all")
	
	sAllText = string.gsub(sAllText, "\t", "     ")
	
	io.close(hReadingFile)
	
	return tostring(sAllText)	
	
end
Thanks
User avatar
balala
Rainmeter Sage
Posts: 8617
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Can I change the contents of skin depending on the language?

balala » May 17th, 2019, 2:12 pm

Not sure what is the content of the ActLang file and what is its format. It doesn't have an extension?
However, how to procced, depends on how often are you switching between the languages. If you're changing those frequently, you have to read all three languages and dynamically switch between them, but if on contrary, a language once set, is used for a longer period, there is a much better approach.
So, first let's establish, how often are you changing the language?