What is the best way to handle multiple language external text files?

Hey all!

I would love some ideas as to the best way to handle this situation:

The current game that I am working on is a point and click adventure game. There is a lot of text that pops
up on the screen. Everything that you interact with has some text associated with it. Just a sentence or two,
but there are about 200 of them.

Right now, I have it all working with an external module file, called gametext_english.lua

And all that contains is a table, like this:

module(..., package.seeall)  
  
t = {}  
t[1] = {0,"I am text one."}  
t[2] = {0,"I am text two."}  
t[3] = {1,"I am text three."}  
t[4] = {1,"I am text four."}  
t[5] = {0,"I am text five."}  

(the 0’s and 1’s are just setting specific properties of the text.)

And throughout my game, I am simply calling a popText() function and passing it a number
as an argument, like this:

popText(4)  

Which would display “I am text four.” on the screen.

I have all of this working perfectly.

In the future, I would love to support different languages. In my mind, I would just have different language modules called gametext_spanish.lua, gametext_norwegian.lua, etc… allowing the player to switch the current language in-game on the Options screen.

Right now I am using:

gametext = require("gametext\_english")  

Is this an OK way to set it up? Am I able to “unrequire” a module, and then “require” a different one?
Any pointers would be appreciated!

Joe

[import]uid: 8444 topic_id: 4116 reply_id: 304116[/import]