I have a software which logs various events into a database (SQLite). Currently the stored datas are :
- Message
- Date
- Category
- Criticality
The logs are written in the current software language. Which mean that the message :
User "admin" logged in
can become
L'utilisateur "admin" est connecté
if the software is in french.
That's perfect for the user, but sometimes users sends us their log file for analysis and it suddently become very complicated if it's a language that's nobody in the team can understand.
Which lead to my question , what strategy should we use to be able to display the logs in any language supported by our software independently of the original language ? knowing that :
- Using a database is mandatory
- The number of parameter in a logs message can go from 0 to a lot
- The logs message should be understandable into the code
- Exporting or displaying logs should be fast
Currently to write a logs message we are doing something like (C++)
std::string message = translate("User %s logged in"); // using Gettext
message = String::Format(message,userName);
LogsManager::Info(message);
Thanks
Edit The problematic is not to know if we should or not translate logs message but how to make them language independent. Meaning if user switch language during the use of the software ,messages should be displayed/exported in the current language and not in the previous one.