Kaydet (Commit) 999c68f1 authored tarafından Jan Iversen's avatar Jan Iversen Kaydeden (comit) jan iversen

genLang project (awareness)

the genLang project aims at replacing all l10ntools with more
modern versions, based on C++ and lex.

The current extract works basically as a standalone "find" over the
source tree. genLang can use that, but also a more efficient way, by
having translation-worthy files declared in the makefile stubs.

genLang itself is a C++ framework, where each file type is defined as
a class, making it easy to add new file types.

genLang can easily be adopted to transform the help files into e.g.
mediawiki format, and later merge a url back into the code.

The project was first developed (solely by the author) in a non
published branch of OO. This branch was never merged but deleted
and therefore never published.

The files have been adapted to the LO build system and setup.

The primary commit is just to raise awareness, that this is being
developed. The following commit, will update the source code to LO 
standard. Before replacing the old modules a dedicated review will
be asked for.


Change-Id: I4504992474333c476c179903f822bfaf1441cca9
Reviewed-on: https://gerrit.libreoffice.org/22819Reviewed-by: 's avatarjan iversen <jani@documentfoundation.org>
Tested-by: 's avatarjan iversen <jani@documentfoundation.org>
üst b76842f6
...@@ -33,6 +33,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \ ...@@ -33,6 +33,7 @@ $(eval $(call gb_Helper_register_executables,NONE, \
genconv_dict \ genconv_dict \
gendict \ gendict \
genindex_data \ genindex_data \
genlang \
helpex \ helpex \
idxdict \ idxdict \
langsupport \ langsupport \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
$(eval $(call gb_Executable_Executable,genlang))
$(eval $(call gb_Executable_set_include,genlang,\
-I$(SRCDIR)/l10ntools/inc \
$$(INCLUDE) \
))
$(eval $(call gb_Executable_add_scanners,genlang,\
l10ntools/source/gLexPo \
l10ntools/source/gLexSrc \
l10ntools/source/gLexXcu \
l10ntools/source/gLexXcs \
l10ntools/source/gLexXrm \
l10ntools/source/gLexXhp \
l10ntools/source/gLexUlf \
l10ntools/source/gLexTree \
))
$(eval $(call gb_Executable_add_exception_objects,genlang,\
l10ntools/source/gLang \
l10ntools/source/gL10nMem \
l10ntools/source/gL10nMemDB \
l10ntools/source/gHandler \
l10ntools/source/gConvProp \
l10ntools/source/gConv \
l10ntools/source/gConvDB \
l10ntools/source/gConvPo \
l10ntools/source/gConvSrc \
l10ntools/source/gConvXrm \
l10ntools/source/gConvXhp \
l10ntools/source/gConvXcs \
l10ntools/source/gConvXcu \
l10ntools/source/gConvUlf \
l10ntools/source/gConvTree \
))
# vim:set noet sw=4 ts=4:
# localizer for new l10n framework
APP1TARGET= genLang
APP1OBJS= $(OBJFILES)
APP1RPATH= NONE
APP1LINKTYPE= STATIC
APP1LIBS=
APP1STDLIBS=
APP1LIBSALCPPRT=
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
$(MISC)$/%_yy.c : %lex.l
flex -l -w -8 -o$@ $<
# --- Files --------------------------------------------------------
genPO: ALLTAR
+$(PERL) $(SOLARENV)/bin/deliver.pl
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
$(eval $(call gb_Module_Module,l10ntools)) $(eval $(call gb_Module_Module,l10ntools))
$(eval $(call gb_Module_add_targets_for_build,l10ntools,\ $(eval $(call gb_Module_add_targets_for_build,l10ntools,\
Executable_genlang \
Executable_helpex \ Executable_helpex \
Executable_idxdict \ Executable_idxdict \
Executable_ulfex \ Executable_ulfex \
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCON_HXX
#define GCON_HXX
#include "gLang.hxx"
#include <iostream>
#include <fstream>
/*****************************************************************************
**************************** G C O N . H X X ****************************
*****************************************************************************
* This is the class definition header for all converter classes,
* all classes and their interrelations is defined here
*****************************************************************************/
/******************* G L O B A L D E F I N I T I O N *******************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_gen_impl
{
public:
static convert_gen_impl *mcImpl;
convert_gen_impl(l10nMem& crMemory);
virtual ~convert_gen_impl();
// all converters MUST implement this function
virtual void execute() = 0;
// ONLY po should implement these functions
virtual void startSave(const std::string& sLanguage,
const std::string& sFile);
virtual void save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy);
virtual void endSave();
// generic variables
bool mbMergeMode;
bool mbLoadMode;
std::string msSourcePath;
std::string msTargetPath;
std::string msSourceFile;
l10nMem& mcMemory;
std::string msCollector;
int miLineNo;
// utility functions for converters
void lexRead (char *sBuf, int *nResult, int nMax_size);
void writeSourceFile(const std::string& line);
std::string& copySource (char *yyText, bool bDoClear = true);
protected:
std::string msSourceBuffer, msCopyText;
int miSourceReadIndex;
bool prepareFile();
private:
std::ofstream mcOutputFile;
friend class convert_gen;
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONDN_HXX
#define GCONDN_HXX
#include "gConv.hxx"
/*****************************************************************************
************************** G C O N D B . H X X **************************
*****************************************************************************
* This is the class header for loading/writing internal "object" files
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_db : public convert_gen_impl
{
public:
convert_db(l10nMem& crMemory);
~convert_db();
private:
static const int NUMFIELD = 16;
std::string msFields[NUMFIELD];
int miSize;
void execute();
bool collectLine();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONPO_HXX
#define GCONPO_HXX
#include "gConv.hxx"
/*****************************************************************************
************************** G C O N P O . H X X **************************
*****************************************************************************
* This is the class header for .po conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_po : public convert_gen_impl
{
public:
bool mbExpectId;
bool mbExpectStr;
convert_po(l10nMem& crMemory);
~convert_po();
void startLook ();
void setValue (char *syyText, int iLineCnt);
void setFuzzy ();
void setKey (char *syyText);
void setMsgId ();
void setMsgStr ();
void handleNL ();
private:
std::string msId;
std::string msStr;
std::string msKey;
bool mbFuzzy;
std::filebuf outBuffer;
void execute();
void startSave(const std::string& sLanguage,
const std::string& sFile);
void save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy);
void endSave();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONPROP_HXX
#define GCONPROP_HXX
#include "gConv.hxx"
/*****************************************************************************
************************ G C O N P R O P . H X X ************************
*****************************************************************************
* This is the class header for .proporties conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_prop : public convert_gen_impl
{
public:
convert_prop(l10nMem& crMemory);
~convert_prop();
private:
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONSRCHXX
#define GCONSRCHXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N S R C . H X X *************************
*****************************************************************************
* This is the class header for .src conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_src : public convert_gen_impl
{
public:
bool mbExpectValue;
convert_src(l10nMem& crMemory);
~convert_src();
void setValue (char *syyText, char *sbuildValue);
void setLang (char *syyText, bool bEnUs);
void setId (char *syyText, bool bIde);
void setText (char *syyText);
void setName (char *syyText);
void setCmd (char *syyText);
void setMacro (char *syyText);
void setList (char *syyText);
void setListItem (char *syyText, bool bIsStart);
void setNL (char *syyText, bool bMacro);
void startBlock (char *syyText);
void stopBlock (char *syyText);
private:
std::vector<std::string> mcStack;
std::string msValue;
std::string msName;
std::string msTextName;
std::string msCmd;
bool mbEnUs;
bool mbExpectName;
bool mbExpectMacro;
bool mbAutoPush;
bool mbValuePresent;
bool mbInList;
bool mbInListItem;
int miListCount;
int miMacroLevel;
void execute();
void trim(std::string& sText);
void buildKey(std::string& sKey);
void insertLanguagePart(std::string& sKey, std::string& sTextType);
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONTREE_HXX
#define GCONTREE_HXX
#include "gConv.hxx"
/*****************************************************************************
************************ G C O N T R E E . H X X ************************
*****************************************************************************
* This is the class header for .tree conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_tree : public convert_gen_impl
{
public:
typedef enum
{
STATE_TAG_NONE,
STATE_TAG_HELPSEC,
STATE_TAG_NODE,
STATE_TAG_TOPIC,
STATE_TAG_VALUE
} STATE_TAG;
typedef enum
{
STATE_VAL_NONE,
STATE_VAL_APPL,
STATE_VAL_ID,
STATE_VAL_TITLE
} STATE_VAL;
convert_tree(l10nMem& crMemory);
~convert_tree();
void setString (char *yytext);
void setState (char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL);
void setValue (char *yytext);
std::string& copySourceSpecial (char *yytext, int iType);
void writeSourceFile (std::string& sText, int inx);
private:
std::string msLine;
std::string msId;
std::string msAppl;
std::ofstream *mcOutputFiles;
STATE_TAG meStateTag;
STATE_VAL meStateVal;
int miCntLanguages;
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONULF_HXX
#define GCONULF_HXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N U L F . H X X *************************
*****************************************************************************
* This is the class header for .ulf conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_ulf : public convert_gen_impl
{
public:
convert_ulf(l10nMem& crMemory);
~convert_ulf();
void setKey(char *syyText);
void setText(char *syyText, bool bIsEnUs);
void setValue(char *syyText);
private:
std::string msKey;
void execute();
void handleLines();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONXCS_HXX
#define GCONXCS_HXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N X C S . H X X *************************
*****************************************************************************
* This is the class header for .xcs conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_xcs : public convert_gen_impl
{
public:
convert_xcs(l10nMem& crMemory);
~convert_xcs();
void setKey(char *syyText);
void unsetKey(char *syyText);
void startCollectData(char *syyText);
void stopCollectData(char *syyText);
private:
std::string msKey;
bool mbCollectingData;
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONXCU_HXX
#define GCONXCU_HXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N X C U . H X X *************************
*****************************************************************************
* This is the class header for .xcu conversion
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class xcu_stack_entry;
class convert_xcu : public convert_gen_impl
{
public:
bool mbNoCollectingData;
convert_xcu(l10nMem& crMemory);
~convert_xcu();
void pushKey(char *syyText);
void popKey(char *syyText);
void startCollectData(char *syyText);
void stopCollectData(char *syyText);
void copySpecial(char *syyText);
void copyNL(char *syyText);
void addLevel();
private:
std::vector<std::string> mcStack;
int miLevel;
bool mbNoTranslate;
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONXHP_HXX
#define GCONXHP_HXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N X H P . H X X *************************
*****************************************************************************
* This is the class definition header xhp converter
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_xhp : public convert_gen_impl
{
public:
convert_xhp(l10nMem& crMemory);
~convert_xhp();
void setString(char *yytext);
void openTag(char *yytext);
void closeTag(char *yytext);
void closeTagNOvalue(char *yytext);
void setId(char *yytext);
void setLang(char *yytext);
void setRef(char *yytext);
void openTransTag(char *yytext);
void closeTransTag(char *yytext);
void stopTransTag(char *yytext);
void startComment(char *yytext);
void stopComment(char *yytext);
void handleSpecial(char *yytext);
void handleDataEnd(char *yytext);
void duplicate(char *yytext);
std::string& copySourceSpecial(char *yytext, int iType);
void writeSourceFile(std::string& sText, int inx);
private:
typedef enum
{
VALUE_NOT_USED,
VALUE_IS_TAG,
VALUE_IS_TAG_TRANS,
VALUE_IS_VALUE,
VALUE_IS_VALUE_TAG
} STATE;
STATE meExpectValue, mePushValue;
std::string msKey, msPushCollect;
std::string msLine;
std::string *msLangText;
std::ofstream *mcOutputFiles;
int miCntLanguages;
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GCONXRM_HXX
#define GCONXRM_HXX
#include "gConv.hxx"
/*****************************************************************************
************************* G C O N X R M . H X X *************************
*****************************************************************************
* This is the class definition header xrm converter
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class convert_xrm : public convert_gen_impl
{
public:
bool mbNoCollectingData;
convert_xrm(l10nMem& crMemory);
~convert_xrm();
void setId(char *yytext);
void setLang(char *yytext);
void setTag(char *yytext);
void startCollectData(char *yytext);
void stopCollectData(char *yytext);
private:
std::string msKey;
bool mbIsTag;
bool mbIsLang;
std::string msTag;
void execute();
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GL10NMEM_HXX
#define GL10NMEM_HXX
#include "gLang.hxx"
/*****************************************************************************
************************ G L 1 0 N M E M . H X X ************************
*****************************************************************************
* This is the class definition header of the l10n localizer program,
* all global classes and their interrelations is defined here
*****************************************************************************/
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_lang_entry
{
public:
l10nMem_lang_entry(const std::string& sMsgStr, bool bFuzzy);
~l10nMem_lang_entry();
std::string msMsgStr; // translated text from po file
bool mbFuzzy; // fuzzy flag
};
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_enus_entry
{
public:
l10nMem_enus_entry(const std::string& sKey,
const std::string& sMsgId,
int iLineNo,
int iFileInx,
int iLangSize,
l10nMem::ENTRY_STATE eState);
~l10nMem_enus_entry();
std::string msKey; // key in po file and source file
std::string msMsgId; // en-US text from source file
l10nMem::ENTRY_STATE meState; // status information
int miFileInx; // index of file name
int miLineNo; // line number
std::vector<l10nMem_lang_entry> mcLangText; // language texts (index is languageId)
};
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_file_entry
{
public:
l10nMem_file_entry(const std::string& sFileName, int iStart);
~l10nMem_file_entry();
std::string msFileName; // file Name with relative path
std::string msPureName; // just filename
int miStart; // start index of entries in mcMasterEntries (l10Mem_db::mcENUS)
int miEnd; // last index of entries in mcMasterEntries (l10Mem_db::mcENUS)
};
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_lang_list_entry
{
public:
l10nMem_lang_list_entry(const std::string& sName);
~l10nMem_lang_list_entry();
std::string msName; // language Name
bool mbChanged; // used for "convert", true if language is modified
};
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_db
{
public:
l10nMem_db();
~l10nMem_db();
int miCurFileInx;
int miCurLangInx;
int miCurENUSinx;
bool mbNeedWrite;
bool mbConvertMode;
bool mbStrictMode;
std::vector<l10nMem_enus_entry> mcENUSlist;
std::vector<l10nMem_file_entry> mcFileList;
std::vector<l10nMem_lang_list_entry> mcLangList;
void loadENUSkey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId);
void setLanguage (const std::string& sLanguage,
bool bCreate);
void setConvert (bool bConvert,
bool bStrict);
bool findFileName (const std::string& sSourceFile);
void loadLangKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId,
const std::string& sMsgStr,
bool bFuzzy);
bool locateKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId,
bool bThrow);
void reorganize (bool bConvert);
void addKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId,
l10nMem::ENTRY_STATE eStat);
int prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
bool getLangList (std::string& sLang);
static void keyToUpper(std::string& sKey);
};
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_impl
{
public:
l10nMem_impl();
~l10nMem_impl();
int showError (const std::string& sText, int iLineNo);
int showWarning (const std::string& sText, int iLineNo);
void showDebug (const std::string& sText, int iLineNo);
void showVerbose (const std::string& sText, int iLineNo);
void setModuleName (const std::string& sModuleName);
const std::string& getModuleName (void);
void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId,
const std::string& sMsgStr,
bool bIsFuzzy);
void setSourceKey (int iLineNo,
const std::string& sFilename,
const std::string& sKey,
const std::string& sMsgId,
bool bMustExist);
void saveTemplates (l10nMem& cMem,
const std::string& sTargetDir,
bool bKid,
bool bForce);
void saveLanguages (l10nMem& cMem,
const std::string& sTargetDir,
bool bForce);
void dumpMem (const std::string& sTargetDir);
void showNOconvert();
void convertToInetString(std::string& sText);
void convertFromInetString(std::string& sText);
private:
static bool mbVerbose;
static bool mbDebug;
static l10nMem_impl *mcImpl;
l10nMem_db mcDb;
std::string msModuleName;
bool mbInError;
void formatAndShowText(const std::string& sType, int iLineNo, const std::string& sText);
bool needWrite (const std::string sFileName, bool bForce);
bool convFilterWarning(const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId);
void convEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sMsgId,
const std::string& sMsgStr,
bool bIsFuzzy);
friend class l10nMem;
};
#endif
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef GLANG_HXX
#define GLANG_HXX
#include <string>
#include <vector>
/*****************************************************************************
*************************** G L A N G . H X X ***************************
*****************************************************************************
* This is the class definition header of the l10n localizer program,
* all global classes and their interrelations is defined here
*****************************************************************************/
/******************* G L O B A L D E F I N I T I O N *******************/
/******************** C L A S S D E F I N I T I O N ********************/
class l10nMem_impl;
class l10nMem
{
public:
l10nMem();
~l10nMem();
typedef enum
{
ENTRY_DELETED,
ENTRY_ADDED,
ENTRY_CHANGED,
ENTRY_NORMAL
} ENTRY_STATE;
static void setShowVerbose ();
static void setShowDebug ();
static int showError (const std::string& sText, int iLineNo = 0);
static int showWarning (const std::string& sText, int iLineNo = 0);
static void showDebug (const std::string& sText, int iLineNo = 0);
static void showVerbose (const std::string& sText, int iLineNo = 0);
bool isError ();
void setModuleName (const std::string& sModuleName);
const std::string& getModuleName (void);
void setLanguage (const std::string& sLanguage,
bool bCreate);
void setConvert (bool bConvert,
bool bStrict);
void loadEntryKey (int iLineNo,
const std::string& sSourceFile,
const std::string& sKey,
const std::string& sOrgText,
const std::string& sText,
bool bIsFuzzy);
void setSourceKey (int iLineNo,
const std::string& sFilename,
const std::string& sKey,
const std::string& sText,
bool bMustExist);
void saveTemplates (const std::string& sTargetDir,
bool bKid,
bool bForce);
void saveLanguages (const std::string& sTargetDir,
bool bForce);
void dumpMem (const std::string& sTargetDir);
int prepareMerge ();
bool getMergeLang (std::string& sLang,
std::string& sText);
void showNOconvert ();
void convertToInetString(std::string& sText);
void convertFromInetString(std::string& sText);
};
/******************** C L A S S D E F I N I T I O N ********************/
class convert_gen
{
public:
convert_gen(l10nMem& cMemory,
const std::string& sSourceDir,
const std::string& sTargetDir,
const std::string& sSourceFile);
~convert_gen();
// do extract/merge
bool execute(const bool bMerge);
// ONLY po should implement these functions
void startSave(const std::string& sLanguage,
const std::string& sFile);
void save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy);
void endSave();
static bool checkAccess(std::string& sFile);
static bool createDir(std::string& sDir, std::string& sFile);
};
/******************** C L A S S D E F I N I T I O N ********************/
class handler
{
public:
handler();
~handler();
void checkCommandLine(int argc, char *argv[]);
void run();
private:
enum {DO_CONVERT, DO_CONVERT_POT, DO_EXTRACT, DO_EXTRACT_KID, DO_MERGE} meWorkMode;
l10nMem mcMemory;
std::string msModuleName;
std::string msPoOutDir;
std::string msPoDir;
std::string msSourceDir;
std::string msTargetDir;
bool mbForceSave;
std::vector<std::string> mvSourceFiles;
std::vector<std::string> mvLanguages;
void runConvert(bool bPot);
void runExtract(bool bKid);
void runMerge();
void showUsage(std::string& sErr);
void showManual();
void loadL10MEM(bool onlyTemplates);
void readFileWithSources();
};
#endif
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvDB.hxx"
/*****************************************************************************
************************** G C O N D B . C X X **************************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_db::convert_db(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
convert_db::~convert_db() {}
/********************** I M P L E M E N T A T I O N **********************/
void convert_db::execute()
{
std::string newKey;
int i;
msSourceBuffer += '\n';
miSize = msSourceBuffer.size() -1;
miLineNo = 0;
while (collectLine())
{
newKey = msFields[4];
if (msFields[5].size())
newKey += "." + msFields[5];
if (msFields[3].size())
newKey += "." + msFields[3];
for (; (i = msFields[1].find('\\')) != (int)std::string::npos;)
msFields[1][i] = '/';
// handle en-US or lang
mcMemory.loadEntryKey(miLineNo, msFields[1], newKey, msFields[10], msFields[10], false);
}
}
/********************** I M P L E M E N T A T I O N **********************/
bool convert_db::collectLine()
{
int i, iStart;
bool bLineEnd;
++miLineNo;
for (i = 0; i < NUMFIELD; ++i)
msFields[i].clear();
if (miSourceReadIndex >= miSize)
return false;
for (i = 0, bLineEnd = false, iStart = miSourceReadIndex; !bLineEnd; ++miSourceReadIndex)
{
if (msSourceBuffer[miSourceReadIndex] == '\r' ||
msSourceBuffer[miSourceReadIndex] == '\n' ||
miSourceReadIndex == miSize)
bLineEnd = true;
if (msSourceBuffer[miSourceReadIndex] == '\t' || bLineEnd)
{
if (i >= NUMFIELD)
{
l10nMem::showError((char*)"TOO many fields", miLineNo);
}
msFields[i++] = msSourceBuffer.substr(iStart, miSourceReadIndex - iStart);
iStart = miSourceReadIndex +1;
}
}
return true;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvPo.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
/*****************************************************************************
********************** G C O N P O W R A P . C X X **********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_po::convert_po(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mbExpectId(false),
mbExpectStr(false),
mbFuzzy(false)
{
// Po files are handled special
mbLoadMode = true;
}
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_po::~convert_po()
{
}
/********************** I M P L E M E N T A T I O N **********************/
//namespace PoWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_po *)convert_gen_impl::mcImpl)
//#include "gConPo_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::startLook()
{
std::string sFileName, sNewKey;
int i;
if (!msKey.size() || !msId.size())
return;
// split key into filename and real key
i = msKey.find("#");
sFileName = msKey.substr(0, i);
sNewKey = msKey.substr(i+1);
// load in db
if (msId.size())
mcMemory.loadEntryKey(miLineNo, sFileName, sNewKey, msId, msStr, mbFuzzy);
// and prepare for new entry
msKey.clear();
msId.clear();
msStr.clear();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setValue(char *syyText, int iLineCnt)
{
if (mbExpectId)
msId = syyText;
if (mbExpectStr)
msStr = syyText;
mbExpectId =
mbExpectStr = false;
miLineNo += iLineCnt;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setFuzzy()
{
mbFuzzy = true;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setKey(char *syyText)
{
int i;
// Activate "look for msg" mode.
startLook();
// skip "#:" and any blanks
for (syyText += 2; *syyText == ' ' || *syyText == '\t'; ++syyText) ;
msKey = syyText;
// remove trailing blanks
for (i = msKey.size() -1; msKey[i] == '\r' || msKey[i] == ' ' || msKey[i] == '\t'; --i) ;
msKey.erase(i+1);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setMsgId()
{
mbExpectId = true;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::setMsgStr()
{
mbExpectStr = true;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::handleNL()
{
++miLineNo;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::execute()
{
if (mbMergeMode)
throw l10nMem::showError("Merge not implemented");
// PoWrap::yylex();
startLook();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::startSave(const std::string& sLanguage,
const std::string& sFile)
{
std::string sFilePath = msTargetPath + sLanguage + sFile;
outBuffer.open(sFilePath.c_str(), std::ios::out);
if (!outBuffer.is_open())
throw l10nMem::showError("Cannot open " + sFilePath + " for writing");
l10nMem::showDebug("writing file (" + sFilePath + ")");
std::ostream outFile(&outBuffer);
// Set license header
outFile << "#*************************************************************" << std::endl
<< "#*" << std::endl
<< "#* Licensed to the Apache Software Foundation (ASF) under one" << std::endl
<< "#* or more contributor license agreements. See the NOTICE file" << std::endl
<< "#* distributed with this work for additional information" << std::endl
<< "#* regarding copyright ownership. The ASF licenses this file" << std::endl
<< "#* to you under the Apache License, Version 2.0 (the" << std::endl
<< "#* \"License\"); you may not use this file except in compliance" << std::endl
<< "#* with the License. You may obtain a copy of the License at" << std::endl
<< "#*" << std::endl
<< "#* http://www.apache.org/licenses/LICENSE-2.0" << std::endl
<< "#*" << std::endl
<< "#* Unless required by applicable law or agreed to in writing," << std::endl
<< "#* software distributed under the License is distributed on an" << std::endl
<< "#* \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY" << std::endl
<< "#* KIND, either express or implied. See the License for the" << std::endl
<< "#* specific language governing permissions and limitations" << std::endl
<< "#* under the License." << std::endl
<< "#*" << std::endl
<< "#************************************************************" << std::endl
<< "msgid \"\"" << std::endl
<< "msgstr \"\"" << std::endl
<< "\"Project-Id-Version: AOO-4-xx\\n\"" << std::endl
<< "\"POT-Creation-Date: \\n\"" << std::endl
<< "\"PO-Revision-Date: \\n\"" << std::endl
<< "\"Last-Translator: genLang (build process)\\n\"" << std::endl
<< "\"Language-Team: \\n\"" << std::endl
<< "\"MIME-Version: 1.0\\n\"" << std::endl
<< "\"Content-Type: text/plain; charset=UTF-8\\n\"" << std::endl
<< "\"Content-Transfer-Encoding: 8bit\\n\"" << std::endl
<< "\"X-Generator: genLang\\n\"" << std::endl
<< std::endl;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::save(const std::string& sFileName,
const std::string& sKey,
const std::string& sENUStext,
const std::string& sText,
bool bFuzzy)
{
std::ostream outFile(&outBuffer);
outFile << std::endl << "#: " << sFileName << "#" << sKey << std::endl;
if (bFuzzy)
outFile << "#, fuzzy" << std::endl;
outFile << "msgid \"" << sENUStext << "\"" << std::endl
<< "msgstr \"" << sText << "\"" << std::endl;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_po::endSave()
{
outBuffer.close();
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvProp.hxx"
/*****************************************************************************
************************ G C O N P R O P . C X X ************************
*****************************************************************************
* This is the conversion for .properties files
*****************************************************************************/
/********************** I M P L E M E N T A T I O N **********************/
convert_prop::convert_prop(l10nMem& crMemory) : convert_gen_impl(crMemory)
{
throw mcMemory.showError(std::string("convert_prop not implemented"));
}
/********************** I M P L E M E N T A T I O N **********************/
convert_prop::~convert_prop()
{
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_prop::execute()
{
throw mcMemory.showError(std::string("convert_prop::execute not implemented"));
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvSrc.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <sstream>
#include <string.h>
/*****************************************************************************
********************* G C O N S R C W R A P . C X X *********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_src::convert_src(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mbExpectValue(false),
mbEnUs(false),
mbExpectName(false),
mbExpectMacro(false),
mbAutoPush(false),
mbValuePresent(false),
mbInList(false),
mbInListItem(false)
{}
convert_src::~convert_src()
{}
/********************** I M P L E M E N T A T I O N **********************/
//namespace SrcWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_src *)convert_gen_impl::mcImpl)
//#include "gConSrc_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::execute()
{
// SrcWrap::yylex();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setValue(char *syyText, char *sbuildValue)
{
copySource(syyText);
if (mbInList && !mbInListItem)
{
setListItem((char *)"", true);
setListItem((char *)"", false);
}
msValue = sbuildValue;
mbValuePresent = true;
mbExpectValue = false;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setLang(char *syyText, bool bEnUs)
{
std::string useText = copySource(syyText) + " is no en-US language";
mbEnUs = bEnUs;
if (!bEnUs && mbExpectValue)
mcMemory.showError(useText);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setId(char *syyText, bool bId)
{
copySource(syyText);
if (bId || !mcStack.back().size())
mbExpectName = mbAutoPush = true;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setText(char *syyText)
{
msTextName = copySource(syyText);
mbExpectValue = true;
mbEnUs = false;
trim(msTextName);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setName(char *syyText)
{
std::string useText = copySource(syyText);
trim(useText);
if (mbExpectName)
{
mbExpectName = false;
if (!mbAutoPush)
msName = useText;
else
{
mbAutoPush = false;
if (mcStack.size())
mcStack.pop_back();
mcStack.push_back(useText);
}
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setCmd(char *syyText)
{
msCmd = copySource(syyText);
mbExpectName = true;
mbInList = false;
trim(msCmd);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setMacro(char *syyText)
{
msCmd = copySource(syyText);
mbExpectName =
mbExpectMacro =
mbAutoPush = true;
miMacroLevel = mcStack.size();
mcStack.push_back("");
trim(msCmd);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setList(char *syyText)
{
msCmd = copySource(syyText);
miListCount = 0;
mbInList = true;
trim(msCmd);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setNL(char *syyText, bool bMacro)
{
int nL;
std::string sKey;
copySource(syyText);
if (msTextName.size() && mbValuePresent && mbEnUs)
{
// locate key and extract it
buildKey(sKey);
for (nL = -1;;)
{
nL = msValue.find("\\\"", nL+1);
if (nL == (int)std::string::npos)
break;
msValue.erase(nL,1);
}
for (nL = -1;;)
{
nL = msValue.find("\\\\", nL+1);
if (nL == (int)std::string::npos)
break;
msValue.erase(nL,1);
}
sKey += "." + msCmd + "." + msTextName;
if (msValue.size() && msValue != "-")
{
mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, msValue, mbMergeMode);
if (mbMergeMode)
insertLanguagePart(sKey, msTextName);
}
}
if (!bMacro && mbExpectMacro)
{
while ((int)mcStack.size() > miMacroLevel)
mcStack.pop_back();
mbEnUs =
mbExpectMacro = false;
}
mbValuePresent =
mbExpectName =
mbAutoPush = false;
msValue.clear();
msTextName.clear();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::startBlock(char *syyText)
{
copySource(syyText);
mcStack.push_back(msName);
msName.clear();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::stopBlock(char *syyText)
{
copySource(syyText);
// check for correct node/prop relations
if (mcStack.size())
mcStack.pop_back();
mbInList =
mbEnUs = false;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::setListItem(char *syyText, bool bIsStart)
{
copySource(syyText);
if (bIsStart)
{
if (!miListCount)
{
mcStack.pop_back();
msName = "dummy";
mcStack.push_back(msName);
}
msTextName = "item";
mbExpectValue =
mbExpectName =
mbInListItem = true;
msName.clear();
}
else
{
if (mbInListItem)
{
std::stringstream ssBuf;
std::string myKey;
++miListCount;
mcStack.pop_back();
if (mbExpectName)
{
ssBuf << miListCount;
msName = "item" + ssBuf.str();
}
mcStack.push_back(msName);
mbInListItem =
mbExpectName = false;
// check key or add seq.
buildKey(myKey);
}
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::trim(std::string& sText)
{
int nL;
while (sText[0] == ' ' || sText[0] == '\t')
sText.erase(0,1);
for (nL = sText.size(); sText[nL-1] == ' ' || sText[nL-1] == '\t'; --nL);
if (nL != (int)sText.size())
sText.erase(nL);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::buildKey(std::string& sKey)
{
int nL;
sKey.clear();
for (nL = 0; nL < (int)mcStack.size(); ++nL)
if (mcStack[nL].size())
sKey += (sKey.size() ? "." : "") + mcStack[nL];
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_src::insertLanguagePart(std::string& sKey, std::string& sTextType)
{
std::string sLang, sText, sTagText;
// just to please compiler
sKey = sKey;
// prepare to read all languages
mcMemory.prepareMerge();
for (; mcMemory.getMergeLang(sLang, sText);)
{
// Prepare tag start and end
sTagText = sTextType + "[ " + sLang + " ] = \"" + sText + "\" ;" +
(mbExpectMacro ? "\\" : "") + "\n";
writeSourceFile(sTagText);
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvTree.hxx"
/*****************************************************************************
******************** G C O N T R E E W R A P . C X X ********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/********************** I M P L E M E N T A T I O N **********************/
convert_tree::convert_tree(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mcOutputFiles(NULL),
meStateTag(STATE_TAG_NONE),
meStateVal(STATE_VAL_NONE),
miCntLanguages(0)
{
// tree files are written through a local routine
mbLoadMode = true;
}
/********************** I M P L E M E N T A T I O N **********************/
convert_tree::~convert_tree()
{
if (mcOutputFiles)
{
for (int i = 0; i < miCntLanguages; ++i)
mcOutputFiles[i].close();
delete[] mcOutputFiles;
}
}
/********************** I M P L E M E N T A T I O N **********************/
//namespace TreeWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_tree *)convert_gen_impl::mcImpl)
//#include "gConTree_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_tree::execute()
{
std::string sLang;
std::string sFile, sFile2;
if (mbMergeMode)
throw l10nMem::showError("Merge not implemented");
// prepare list with languages
if (mbMergeMode)
{
miCntLanguages = mcMemory.prepareMerge();
mcOutputFiles = new std::ofstream[miCntLanguages];
for (int i = 0; mcMemory.getMergeLang(sLang, sFile); ++i)
{
sFile2 = sLang + "/" + msSourceFile;
sFile = msTargetPath + sFile2;
mcOutputFiles[i].open(sFile.c_str(), std::ios::binary);
if (!mcOutputFiles[i].is_open())
{
if (!convert_gen::createDir(msTargetPath, sFile2))
throw l10nMem::showError("Cannot create missing directories (" + sFile + ") for writing");
mcOutputFiles[i].open(sFile.c_str(), std::ios::binary);
if (!mcOutputFiles[i].is_open())
throw l10nMem::showError("Cannot open file (" + sFile + ") for writing");
}
}
}
// run analyzer
// TreeWrap::yylex();
// dump last line
copySourceSpecial(NULL,3);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_tree::setString(char *yytext)
{
switch (meStateVal)
{
case STATE_VAL_NONE:
copySourceSpecial(yytext, 0);
break;
case STATE_VAL_APPL:
msAppl = copySourceSpecial(yytext, 0);
break;
case STATE_VAL_ID:
msId = copySourceSpecial(yytext, 0);
msId.erase(msId.size()-1);
break;
case STATE_VAL_TITLE:
std::string sText = copySourceSpecial(yytext, 1);
sText.erase(sText.size()-1);
mcMemory.setSourceKey(miLineNo, msSourceFile, msId, sText, mbMergeMode);
break;
}
meStateVal = STATE_VAL_NONE;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_tree::setState(char *yytext, STATE_TAG eNewStateTag, STATE_VAL eNewStateVAL)
{
copySourceSpecial(yytext, 0);
msCollector.clear();
meStateTag = eNewStateTag;
meStateVal = eNewStateVAL;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_tree::setValue(char *yytext)
{
mcMemory.setSourceKey(miLineNo, msSourceFile, msId, msCollector, mbMergeMode);
copySourceSpecial(yytext, 2);
meStateTag = STATE_TAG_NONE;
meStateVal = STATE_VAL_NONE;
}
/********************** I M P L E M E N T A T I O N **********************/
std::string& convert_tree::copySourceSpecial(char *yytext, int iType)
{
std::string& sText = copySource(yytext, false);
std::string sLang, sTemp;
int i;
// Handling depends on iType
switch (iType)
{
case 0: // Used for tokens that are to be copied 1-1,
if (mbMergeMode)
{
msLine += yytext;
if (*yytext == '\n')
{
for (i = 0; i < miCntLanguages; ++i)
writeSourceFile(msLine, i);
msLine.clear();
}
}
break;
case 1: // Used for title token, are to replaced with languages
if (mbMergeMode)
{
mcMemory.prepareMerge();
for (i = 0; i < miCntLanguages; ++i)
{
writeSourceFile(msLine, i);
mcMemory.getMergeLang(sLang, sTemp);
writeSourceFile(sTemp,i);
}
msLine.clear();
}
break;
case 2: // Used for token at end of value, language text are to be inserted and then token written
if (mbMergeMode)
{
mcMemory.prepareMerge();
for (i = 0; i < miCntLanguages; ++i)
{
writeSourceFile(msLine, i);
mcMemory.getMergeLang(sLang, sTemp);
writeSourceFile(sTemp,i);
std::string sYY(yytext);
writeSourceFile(sYY, i);
}
msLine.clear();
}
break;
case 3: // Used for EOF
if (mbMergeMode)
{
for (i = 0; i < miCntLanguages; ++i)
writeSourceFile(msLine, i);
}
break;
}
return sText;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_tree::writeSourceFile(std::string& sText, int inx)
{
if (sText.size() && mcOutputFiles[inx].is_open())
mcOutputFiles[inx].write(sText.c_str(), sText.size());
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvUlf.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
/*****************************************************************************
********************* G C O N X C S W R A P . C X X *********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/********************** I M P L E M E N T A T I O N **********************/
convert_ulf::convert_ulf(l10nMem& crMemory) : convert_gen_impl(crMemory) {}
convert_ulf::~convert_ulf() {}
/********************** I M P L E M E N T A T I O N **********************/
//namespace UlfWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_ulf *)convert_gen_impl::mcImpl)
//#include "gConUlf_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_ulf::execute()
{
// UlfWrap::yylex();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_ulf::setKey(char *syyText)
{
std::string sText = copySource(syyText);
// locate key (is any)
msKey = sText.substr(1,sText.size()-2);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_ulf::setText(char *syyText, bool bIsEnUs)
{
std::string sText = copySource(syyText) + " is not en-US";
if (!bIsEnUs)
mcMemory.showError(sText);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_ulf::setValue(char *syyText)
{
std::string sLang, sText = copySource(syyText);
int nL;
sText.erase(0,1);
nL = sText.rfind("\"");
sText.erase(nL);
mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode);
if (mbMergeMode)
{
// prepare to read all languages
mcMemory.prepareMerge();
for (; mcMemory.getMergeLang(sLang, sText);)
{
// Prepare tag
sText = "\n" + sLang + " = \"" + sText + "\"";
writeSourceFile(sText);
}
}
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvXcs.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
/*****************************************************************************
********************* G C O N X C S W R A P . C X X *********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcs::convert_xcs(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mbCollectingData(false)
{
}
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcs::~convert_xcs()
{
}
/********************** I M P L E M E N T A T I O N **********************/
//namespace XcsWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_xcs *)convert_gen_impl::mcImpl)
//#include "gConXcs_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs::execute()
{
if (mbMergeMode)
throw l10nMem::showError("Merge not implemented");
// currently no .xcs files generate en-US translation, so stop trying
// XcsWrap::yylex();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs::setKey(char *syyText)
{
int nL;
std::string sHead, sText = copySource(syyText);
// is it to be translated
if (sText.find("oor:localized=") == std::string::npos)
return;
// locate key (is any)
nL = sText.find("oor:name=\"");
if (nL == (int)std::string::npos)
return;
sHead = sText.substr(nL+10);
nL = sHead.find("\"");
msKey = sHead.substr(0,nL);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs::unsetKey(char *syyText)
{
copySource(syyText);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs::startCollectData(char *syyText)
{
copySource(syyText);
if (!msKey.size())
return;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcs::stopCollectData(char *syyText)
{
std::string sHead, sKey, sLang, sText, sCollectedText = copySource(syyText, false);
int nL;
// get type of tag
msCollector += sCollectedText;
nL = msCollector.find("<p");
if (nL != (int)std::string::npos)
sHead = msCollector.substr(nL+1, 1);
else
{
nL = msCollector.find("<h");
sHead = msCollector.substr(nL+1, 2);
}
// locate key and extract it
nL = msCollector.find("id=") +4;
sKey = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
nL = msCollector.find("xml:lang=\"") + 10;
sLang = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
nL = msCollector.find(">") +1;
sText = msCollector.substr(nL, msCollector.find("\"", nL+1) - nL);
msCollector.clear();
if (mbMergeMode)
{
#if 0
// get all languages (includes en-US)
std::vector<l10nMem_entry *>& cExtraLangauges = mcMemory.getLanguagesForKey(sKey);
std::string sNewLine;
nL = cExtraLangauges.size();
for (int i = 0; i < nL; ++i)
{
sNewLine = "\n<" + sHead + " id=\"" + sKey + "\"" + " xml:lang=\"" +
cExtraLangauges[i]->msLanguage + "\">" +
cExtraLangauges[i]->msText +
"</" + sHead + ">";
writeSourceFile(sNewLine);
}
#endif
}
mcMemory.setSourceKey(miLineNo, msSourceFile, sKey, sText, mbMergeMode);
mbCollectingData = false;
}
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvXcu.hxx"
#include <iostream>
#include <fstream>
#include <cstdlib>
/*****************************************************************************
********************* G C O N X C U W R A P . C X X *********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcu::convert_xcu(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mbNoCollectingData(true),
miLevel(0),
mbNoTranslate(false)
{
}
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xcu::~convert_xcu()
{
}
/********************** I M P L E M E N T A T I O N **********************/
//namespace XcuWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_xcu *)convert_gen_impl::mcImpl)
//#include "gConXcu_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::execute()
{
// XcuWrap::yylex();
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::pushKey(char *syyText)
{
std::string sKey, sTag = copySource(syyText);
int nL, nE;
// find key in tag
nL = sTag.find("oor:name=\"");
if (nL != (int)std::string::npos)
{
// find end of key
nL += 10;
nE = sTag.find("\"", nL);
if (nE != (int)std::string::npos)
sKey = sTag.substr(nL, nE - nL);
}
mcStack.push_back(sKey);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::popKey(char *syyText)
{
copySource(syyText);
// check for correct node/prop relations
if (mcStack.size())
mcStack.pop_back();
mbNoTranslate = false;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::startCollectData(char *syyText)
{
int nL;
std::string sTag = copySource(syyText);
if (mbNoTranslate)
return;
// locate object name
nL = sTag.find("xml:lang=\"");
if (nL != (int)std::string::npos)
{
// test langauge
nL += 10;
if (sTag.substr(nL,5) == "en-US")
mbNoCollectingData = false;
else if (sTag.substr(nL,14) == "x-no-translate")
mbNoTranslate = true;
else
{
std::string sErr = sTag.substr(nL,5) + " is not en-US";
mcMemory.showError(sErr);
}
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::stopCollectData(char *syyText)
{
int nL;
std::string useKey, useText = msCollector;
copySource(syyText);
// time to do something ?
if (mbNoCollectingData || mbNoTranslate)
return;
// remove any newline
for (nL = 0;;)
{
nL = useText.find("\n");
if (nL == (int)std::string::npos)
break;
useText.erase(nL,1);
}
mbNoCollectingData = true;
if (useText.size())
{
// locate key and extract it
for (nL = 0; nL < (int)mcStack.size(); ++nL)
useKey += (useKey.size() ? "." : "" ) + mcStack[nL];
mcMemory.setSourceKey(miLineNo, msSourceFile, useKey, useText, mbMergeMode);
}
if (mbMergeMode)
{
std::string sLang, sText, sNewLine;
// prepare to read all languages
mcMemory.prepareMerge();
for (; mcMemory.getMergeLang(sLang, sText);)
{
sNewLine = "\n<value xml:lang=\"" + sLang + "\">" + sText + "</value>";
mcMemory.convertToInetString(sNewLine);
writeSourceFile(sNewLine);
}
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::copySpecial(char *syyText)
{
int nx = msCollector.size();
std::string sText = copySource(syyText, mbNoCollectingData);
if (!mbNoCollectingData)
{
msCollector.erase(nx);
mcMemory.convertFromInetString(sText);
msCollector += sText;
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::copyNL(char *syyText)
{
int nX = msCollector.size();
std::string sText = copySource(syyText, mbNoCollectingData);
if (!mbNoCollectingData)
{
msCollector.erase(nX);
msCollector += ' ';
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xcu::addLevel()
{
++miLevel;
}
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gConvXrm.hxx"
/*****************************************************************************
********************* G C O N X R M W R A P . C X X *********************
*****************************************************************************
* This includes the c code generated by flex
*****************************************************************************/
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xrm::convert_xrm(l10nMem& crMemory)
: convert_gen_impl(crMemory),
mbNoCollectingData(true),
mbIsTag(false),
mbIsLang(false)
{
}
/************ I N T E R F A C E I M P L E M E N T A T I O N ************/
convert_xrm::~convert_xrm()
{
}
/********************** I M P L E M E N T A T I O N **********************/
//namespace XrmWrap
//{
//#define IMPLptr convert_gen_impl::mcImpl
//#define LOCptr ((convert_xrm *)convert_gen_impl::mcImpl)
//#include "gConXrm_yy.c"
//}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::execute()
{
//// XrmWrap::yylex();
// write last part of file.
if (mbMergeMode)
writeSourceFile(msCollector);
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::setId(char *yytext)
{
std::string& sText = copySource(yytext, mbNoCollectingData);
int nL, nE;
if (mbIsTag)
{
nL = sText.find("\"");
nE = sText.find("\"", nL+1);
if (nL == (int)std::string::npos || nE == (int)std::string::npos)
return;
msKey = sText.substr(nL+1, nE - nL -1);
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::setLang(char *yytext)
{
std::string& sText = copySource(yytext, mbNoCollectingData);
std::string sLang;
int nL, nE;
if (mbIsTag)
{
nL = sText.find("\"");
nE = sText.find("\"", nL+1);
if (nL == (int)std::string::npos || nE == (int)std::string::npos)
return;
sLang = sText.substr(nL+1, nE - nL -1);
if (sLang == "en-US")
mbIsLang = true;
else
mcMemory.showError(sLang + " is no en-US language");
}
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::setTag(char *yytext)
{
msTag = copySource(yytext);
msKey.clear();
mbIsLang = false;
mbIsTag = true;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::startCollectData(char *yytext)
{
copySource(yytext, mbNoCollectingData);
if (mbIsTag && mbIsLang && msKey.size())
mbNoCollectingData = false;
mbIsTag = mbIsLang = false;
}
/********************** I M P L E M E N T A T I O N **********************/
void convert_xrm::stopCollectData(char *yytext)
{
std::string sTagText, sTagEnd, sLang, sText = msCollector;
copySource(yytext);
if (!mbNoCollectingData)
{
mcMemory.setSourceKey(miLineNo, msSourceFile, msKey, sText, mbMergeMode);
mbNoCollectingData = true;
if (mbMergeMode)
{
sTagEnd = "</" + msTag.substr(1,msTag.size()-2) + ">\n";
msTag += "id=\"" + msKey + "\" xml:lang=\"";
// prepare to read all languages
mcMemory.prepareMerge();
for (; mcMemory.getMergeLang(sLang, sText);)
{
// replace \" with "
for (int i = 0; (i = sText.find("\\\"", i)) != (int)std::string::npos;)
sText.erase(i,1);
// Prepare tag start and end
sTagText = msTag + sLang + "\">" + sText + sTagEnd;
writeSourceFile(sTagText);
}
}
msKey.clear();
}
mbIsTag = false;
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "gLang.hxx"
/*****************************************************************************
*************************** G L A N G . C X X ***************************
*****************************************************************************
* This is the main of the l10n localizer program, it is C based and call
* down to classes for handling.
*****************************************************************************/
/********************** I M P L E M E N T A T I O N **********************/
#if defined(UNX) || defined(OS2)
int main(int argc, char *argv[])
#else
int _cdecl main(int argc, char *argv[])
#endif
{
handler cHandler;
// check command line (exit if problems)
cHandler.checkCommandLine(argc, argv);
// command line is ok, so execute it
cHandler.run();
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment