示例#1
0
static cell_t sm_LoadTranslations(IPluginContext *pCtx, const cell_t *params)
{
	char *filename, *ext;
	char buffer[PLATFORM_MAX_PATH];
	IPlugin *pl = pluginsys->FindPluginByContext(pCtx->GetContext());

	pCtx->LocalToString(params[1], &filename);
	ke::SafeSprintf(buffer, sizeof(buffer), "%s", filename);

	/* Make sure there is no extension */
	if ((ext = strstr(buffer, ".txt")) != NULL
		|| (ext = strstr(buffer, ".cfg")) != NULL)
	{
		/* Simple heuristic -- just see if it's at the end and terminate if so */
		if ((unsigned)(ext - buffer) == strlen(buffer) - 4)
		{
			*ext = '\0';
		}
	}

	pl->GetPhrases()->AddPhraseFile(buffer);

	return 1;
}