Skip to content

Commit

Permalink
Check language mismatch.
Browse files Browse the repository at this point in the history
  • Loading branch information
gabordemooij committed Aug 3, 2018
1 parent 4270a9a commit e946be7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions citrine.h
@@ -1,8 +1,10 @@

#ifdef langNL
#include "i18n/nl/dictionarynl.h"
#include "i18n/nl/msgnl.h"
#else
#include "dictionary.h"
#include "i18n/en_us/msg.h"
#endif

#include <inttypes.h>
Expand Down Expand Up @@ -727,3 +729,5 @@ extern void ctr_clex_move_code_pointer(int movement);
extern int ctr_clex_forward_scan( char* codePointer, char* bytes, ctr_size* newCodePointer );
extern int ctr_clex_backward_scan( char* codePointer, char* bytes, ctr_size* newCodePointer, ctr_size limit );
extern void ctr_print_error(char* error, int code);

extern void ctr_plugin_check_language( char* code );
1 change: 1 addition & 0 deletions plugins/request/request.c
Expand Up @@ -317,6 +317,7 @@ ctr_object* ctr_request_serve(ctr_object* myself, ctr_argument* argumentList) {
* Adds the Request object to the World.
*/
void begin(){
ctr_plugin_check_language( CTR_MSG_LANG_CODE );
ctr_object* requestObject = ctr_internal_create_object(CTR_OBJECT_TYPE_OTOBJECT);
requestObject->link = CtrStdObject;
ctr_internal_create_func(requestObject, ctr_build_string_from_cstring( CTR_DICT_HTTP_REQUEST_GET_SET ), &ctr_request_get_string );
Expand Down
16 changes: 16 additions & 0 deletions util.c
Expand Up @@ -166,6 +166,22 @@ ctr_object* ctr_error_text( char* message ) {
return CtrStdFlow;
}

/**
* @internal
*
* Checks the language of the build with the language
* of the plugin.
*/
void ctr_plugin_check_language( char* code ) {
int l = strlen(code);
if ( l == strlen(CTR_MSG_LANG_CODE) ) {
if ( strncmp( code, CTR_MSG_LANG_CODE, l ) == 0 ) {
return;
}
}
ctr_print_error("Language mismatch.", 1);
}

/**
* @internal
*
Expand Down

0 comments on commit e946be7

Please sign in to comment.