06.10.2013, 13:01
(
Последний раз редактировалось GiamPy.; 06.10.2013 в 15:24.
)
sqlitelang.inc - SQLite based include that easily allows to manipulate multilanguage strings.
"Creating multilanguage gamemodes has never been easier."
Include release under GPL v2 OSL (open source license) - click here for more information.
Hello everyone.
Yesterday (05OCT2013) I have published in the discussions section a thread for ideas and feedback regarding this new project I have been working on recently. The purpose of this include is allowing developers to have an easier life in making multi-language strings.
I am copy-pasting a piece of the thread I have posted in the discussions section as it's quite important:
This one I am releasing is a beta version, which means all the features have been added but their functioning hasn't been yet recognized as stable or working. Let's say this is the testing phase. This will allow me, you, everyone (as it's released on GitHub, everyone will be able to push pull requests and contribute to the include) to improve and fix eventual bugs in which you occurred.
Available Functions
Tutorial
The process to install SQLiteLang is really simple.
You need to includeinside your gamemode and, wherever you want (it's prefered in OnGameModeInit), add the function SQLiteLang_Initialize.
As you can see above in the function documentation, you may decide a specific directory for the database and if activating the debug mode (it's prefered in the beta version so you are able to actually see what's wrong).
If the database does not exist, the include will create one automatically for you with one identifier, one language and one string added for demo purposes (first_string as the identifier, en as language and "This is your first string!" under first_string en).
Warning
I remind everyone that the include hasn't got any internal escaping mechanism, so remember that if you are willing to make those functions available for users in-game to escape every string.
For any other question, feedback or anything else feel free to answer this thread, and don't forget to contribute on GitHub, if you'd like to!
Cheers.
"Creating multilanguage gamemodes has never been easier."
Include release under GPL v2 OSL (open source license) - click here for more information.
Hello everyone.
Yesterday (05OCT2013) I have published in the discussions section a thread for ideas and feedback regarding this new project I have been working on recently. The purpose of this include is allowing developers to have an easier life in making multi-language strings.
I am copy-pasting a piece of the thread I have posted in the discussions section as it's quite important:
Quote:
First off, to be honest this include is similar to y_language from a certain point of view, however SQLite makes it way more developer-friendly and adds many functions that allow developers to add, modify, delete or manipulate in any possible way the strings in-game! Developers will be able to make systems to allow users giving a contribute to the server making user-made translations for their own language, for example. |
Available Functions
- SQLiteLang_Initialize(file[])
- SQLiteLang_Terminate()
- SQLiteLang_AddIdentifierString(identifier[], description[])
- SQLiteLang_DeleteIdentifier(identifier[])
- SQLiteLang_ModifyIdentifierDescription(identifier[], new_desc[])
- SQLiteLang_AddString(identifier[], lang[], string[])
- SQLiteLang_DeleteString(identifier[], lang[])
- SQLiteLang_ModifyString(identifier[], lang[], new_string[])
- SQLiteLang_AddLanguage(lang[], description[])
- SQLiteLang_DeleteLanguage(lang[])
- SQLiteLang_ModifyLanguage(old_lang[], new_lang[])
- SQLiteLang_ModifyLanguageDescription(lang[], new_desc[])
- SQLiteLang_ShowLanguageString(identifier[], lang[])
- SQLiteLang_ShowPlayerString(playerid, identifier[])
- SQLiteLang_SetDefaultLang(lang[])
- SQLiteLang_SetPlayerLang(playerid, lang[])
- SQLiteLang_IsIdentifierValid(identifier[])
- SQLiteLang_IsLanguageValid(lang[])
- SQLiteLang_IsStringValid(identifier[], lang[])
pawn Код:
/*
* SQLiteLang_Initialize
* This function declares the name of the database and saves it into a variable (both file and directory).
* If the database does not exist, a new one will be created by default in the folder 'SQLiteLang'.
*
* optional: file[] ("SQLiteLang/Database/Database.db") = Directory and file name of the database.
* optional: bool:init_debug (false) = Turning this on will activate the debugging mode.
*/
/*
* SQLiteLang_Terminate
* This function terminates the usage of the include and resets the saved name and directory of the database internally to default.
*/
/*
* SQLiteLang_AddIdentifier
* This function adds a new string identifier to the database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* description[] = The description of the identifier (ie. "string that welcomes new players in the server").
*/
/*
* SQLiteLang_DeleteIdentifier
* This function deletes all the language strings of a specific identifier from the database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
*/
/*
* SQLiteLang_ModifyIdentifier
* This function modifies an identifier name to new one.
*
* old_identifier[] = The identifier to be modified.
* new_identifier[] = The new name of the identifier.
*/
/*
* SQLiteLang_ModifyIdentifierDesc
* This function modifies an identifier's description to a new one.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* new_desc[] = The new description of the identifier.
*/
/*
* SQLiteLang_AddLanguage
* This function adds a new language to the database.
*
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
* description[] = The description of the language (ie. "English" or "Italian Language" or "{FFFFFF}Spanish").
*/
/*
* SQLiteLang_DeleteLanguage
* This function deletes a specific language from database.
* Be careful, deleting a language will delete all the language strings already added in the database.
* Furthermore, you may not delete the default language, if set.
*
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_ModifyLanguage
* This function modifies a language name to new one.
*
* old_lang[] = The language to be modified.
* new_lang[] = The new name of the language.
*/
/*
* SQLiteLang_ModifyLanguageDesc
* This function modifies a language's description to a new one.
*
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
* new_desc[] = The new description of the language.
*/
/*
* SQLiteLang_AddString
* This function adds a new string to the database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
* string[] = The string is the actual string of text to show in different languages.
*/
/*
* SQLiteLang_DeleteString
* This function deletes a specific language string of a specific identifier from the database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_ModifyString
* This function modify a specific language string in database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
* new_string[] = The string is the new actual string of text to show in different languages that will replace the old one.
*/
/*
* SQLiteLang_ShowLanguageString
* This function shows a specific language string taken from the database.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* optional: lang[] (default language) = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_ShowPlayerString
* This function shows a specific language string taken from the database.
*
* playerid = playerid of the player.
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
*/
/*
* SQLiteLang_SetDefaultLang
* This function sets the default language for users that haven't selected an available language.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_SetPlayerLang
* This function sets the language of a player.
*
* playerid = playerid of the player.
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_IsIdentifierValid
* This function checks if an identifier exists.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
*/
/*
* SQLiteLang_IsLanguageValid
* This function checks if a language exists.
*
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
/*
* SQLiteLang_IsStringValid
* This function checks if a string already exists.
*
* identifier[] = The identifier is used to identify, as the parameter says, every string of text (ie. "welcome_string").
* lang[] = The lang is used to identify the language of the string (ie. "en" or "IT" or "spanish").
*/
The process to install SQLiteLang is really simple.
You need to includeinside your gamemode and, wherever you want (it's prefered in OnGameModeInit), add the function SQLiteLang_Initialize.
pawn Код:
#include <sqlitelang>
// This will use the default directory which is 'SQLiteLang/Database/Database.db'.
// Make sure the folder 'SQLiteLang' exists or the automatic process will not work.
SQLiteLang_Initialize(.init_debug = true);
If the database does not exist, the include will create one automatically for you with one identifier, one language and one string added for demo purposes (first_string as the identifier, en as language and "This is your first string!" under first_string en).
Warning
I remind everyone that the include hasn't got any internal escaping mechanism, so remember that if you are willing to make those functions available for users in-game to escape every string.
For any other question, feedback or anything else feel free to answer this thread, and don't forget to contribute on GitHub, if you'd like to!
Cheers.