summaryrefslogtreecommitdiff
path: root/l10ntools/inc
diff options
context:
space:
mode:
authorJan Iversen <jani@documentfoundation.org>2016-03-01 18:07:54 +0100
committerjan iversen <jani@documentfoundation.org>2016-03-03 07:46:59 +0000
commit999c68f12f1d95b16a97294949a0e6ba6d3ba259 (patch)
tree0abb13f0fa1ab353771f1eda05e4abadc554ef2c /l10ntools/inc
parentb76842f63b19e9855fbdfee7c201ff73672464b6 (diff)
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/22819 Reviewed-by: jan iversen <jani@documentfoundation.org> Tested-by: jan iversen <jani@documentfoundation.org>
Diffstat (limited to 'l10ntools/inc')
-rw-r--r--l10ntools/inc/gConv.hxx92
-rw-r--r--l10ntools/inc/gConvDB.hxx49
-rw-r--r--l10ntools/inc/gConvPo.hxx71
-rw-r--r--l10ntools/inc/gConvProp.hxx45
-rw-r--r--l10ntools/inc/gConvSrc.hxx75
-rw-r--r--l10ntools/inc/gConvTree.hxx75
-rw-r--r--l10ntools/inc/gConvUlf.hxx52
-rw-r--r--l10ntools/inc/gConvXcs.hxx52
-rw-r--r--l10ntools/inc/gConvXcu.hxx60
-rw-r--r--l10ntools/inc/gConvXhp.hxx77
-rw-r--r--l10ntools/inc/gConvXrm.hxx56
-rw-r--r--l10ntools/inc/gL10nMem.hxx217
-rw-r--r--l10ntools/inc/gLang.hxx164
13 files changed, 1085 insertions, 0 deletions
diff --git a/l10ntools/inc/gConv.hxx b/l10ntools/inc/gConv.hxx
new file mode 100644
index 000000000000..5b79e4ad55a4
--- /dev/null
+++ b/l10ntools/inc/gConv.hxx
@@ -0,0 +1,92 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvDB.hxx b/l10ntools/inc/gConvDB.hxx
new file mode 100644
index 000000000000..54dba4e00c28
--- /dev/null
+++ b/l10ntools/inc/gConvDB.hxx
@@ -0,0 +1,49 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvPo.hxx b/l10ntools/inc/gConvPo.hxx
new file mode 100644
index 000000000000..7d2d8f25ac44
--- /dev/null
+++ b/l10ntools/inc/gConvPo.hxx
@@ -0,0 +1,71 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvProp.hxx b/l10ntools/inc/gConvProp.hxx
new file mode 100644
index 000000000000..ce2ee3833411
--- /dev/null
+++ b/l10ntools/inc/gConvProp.hxx
@@ -0,0 +1,45 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvSrc.hxx b/l10ntools/inc/gConvSrc.hxx
new file mode 100644
index 000000000000..e8de3708a359
--- /dev/null
+++ b/l10ntools/inc/gConvSrc.hxx
@@ -0,0 +1,75 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvTree.hxx b/l10ntools/inc/gConvTree.hxx
new file mode 100644
index 000000000000..0ec25ade4cb2
--- /dev/null
+++ b/l10ntools/inc/gConvTree.hxx
@@ -0,0 +1,75 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvUlf.hxx b/l10ntools/inc/gConvUlf.hxx
new file mode 100644
index 000000000000..30e79ad6ccca
--- /dev/null
+++ b/l10ntools/inc/gConvUlf.hxx
@@ -0,0 +1,52 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvXcs.hxx b/l10ntools/inc/gConvXcs.hxx
new file mode 100644
index 000000000000..d1b241eb81cd
--- /dev/null
+++ b/l10ntools/inc/gConvXcs.hxx
@@ -0,0 +1,52 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvXcu.hxx b/l10ntools/inc/gConvXcu.hxx
new file mode 100644
index 000000000000..db106278b630
--- /dev/null
+++ b/l10ntools/inc/gConvXcu.hxx
@@ -0,0 +1,60 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvXhp.hxx b/l10ntools/inc/gConvXhp.hxx
new file mode 100644
index 000000000000..857966f16d0c
--- /dev/null
+++ b/l10ntools/inc/gConvXhp.hxx
@@ -0,0 +1,77 @@
+/* -*- 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
diff --git a/l10ntools/inc/gConvXrm.hxx b/l10ntools/inc/gConvXrm.hxx
new file mode 100644
index 000000000000..e10d9998383d
--- /dev/null
+++ b/l10ntools/inc/gConvXrm.hxx
@@ -0,0 +1,56 @@
+/* -*- 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
diff --git a/l10ntools/inc/gL10nMem.hxx b/l10ntools/inc/gL10nMem.hxx
new file mode 100644
index 000000000000..1da50af28bcc
--- /dev/null
+++ b/l10ntools/inc/gL10nMem.hxx
@@ -0,0 +1,217 @@
+/* -*- 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
diff --git a/l10ntools/inc/gLang.hxx b/l10ntools/inc/gLang.hxx
new file mode 100644
index 000000000000..be1422ba3f8f
--- /dev/null
+++ b/l10ntools/inc/gLang.hxx
@@ -0,0 +1,164 @@
+/* -*- 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