I´m working with Preside, that has some
.properties extension files used for labing and translating the web content.
In our app we can have several
xxx.properties with others
xxx is the name of the property and
yy the language translation. The ones without
yy are the default language.
Here an example for a default property file with his Spanish and French translations files and the labels
add_usser, edit_user, delete_user:
add_user = Add website user edit_user = Edit website user delete_user = Delete website user
add_user = Agregar usuario web edit_user = Editar usuario web delete_user = Eliminar usuario web
add_user = Ajouter un utilisateur du site Web edit_user = Modifier l utilisateur du site Web delete_user = Supprimer l utilisateur du site Web
What I need to do is to create a standalone cfml file that retreives all
.properties files on the application and compare each default .properties file with his other translation files and show the missing labels of the compared file, if they exist.
So far what I can do is to retreive all the property files in a query with the name and path with directoryList and print each one of them.
propertiesFiles = directoryList("/application/i18n/", true, "query", "*.properties", "Directory", "all"); <cfoutput query="propertiesFiles"> #propertiesFiles.name &" "& propertiesFiles.Directory# </cfoutput>
Thanks in advance
Loop functions are one option. The files in question look like a bunch of lines separated by cairraige returns. Then, each line looks like a list separated by equal signs.
Also, there is an online library of user defined functions available for use. It includes a function called ListCompare, that can be applied to this situation.
The first step in my approach would be to write a function named
getLabels that returns a list of labels from each file. It would
- read the file.
- Create a variable named
labelswith a value of an empty string.
- treat the resulting variable as a chr(10) delimited list. Loop through this list and on each iteration, use
ListFirst(delimiter = "=") to get each label, and append that to thelabels` variable.
- return the
The next step would be to use this function to get the labels from file
user.properties. Call this variable
Then start looping through the query created by your
directoryList command. Use the
getLabels function to get the labels from each file and the
listCompare function to identify the missing labels.