VirtualBox

Changeset 92824 in vbox


Ignore:
Timestamp:
Dec 8, 2021 3:18:32 PM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
148747
Message:

Main: bugref:1909: Added handling built-in docbook help for languages other than en_US in the VBoxManage

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/doc/manual/Config.kmk

    r92084 r92824  
    137137# @param    3   The XML file with full path.
    138138# @param    4   Non-empty if xrefs to replace.
     139# @param    5   Language code (optional)
    139140define def_vbox_refentry_preprocess_for_manpage
    140141$(1)/$(2): \
    141142                $(3) \
    142143                $$(VBOX_PATH_MANUAL_SRC)/docbook-refentry-to-manpage-preprocessing.xsl \
    143                 $(if $(4),$$(VBOX_XML_XREF_TO_TEXT),) \
     144                $(if $(4), $$(VBOX_PATH_MANUAL_OUTBASE)/$(5)/xref-to-text.xsl,) \
    144145                $$(VBOX_XML_CATALOG) $$(VBOX_XML_CATALOG_DOCBOOK) $$(VBOX_XML_CATALOG_MANUAL) \
    145146                $$(VBOX_VERSION_STAMP) | $$$$(dir $$$$@)
     
    149150                "$$(VBOX_PATH_MANUAL_SRC)/docbook-refentry-to-manpage-preprocessing.xsl" $$<
    150151ifneq ($(4),)
    151         $$(QUIET)$$(call VBOX_XSLTPROC_WITH_CAT) --output [email protected] $$(VBOX_XML_XREF_TO_TEXT) $$@
     152        $$(QUIET)$$(call VBOX_XSLTPROC_WITH_CAT) --output [email protected] \
     153                $$(VBOX_PATH_MANUAL_OUTBASE)/$(5)/xref-to-text.xsl $$@
    152154        $$(QUIET)$$(MV) -f -- "[email protected]" "$$@"
    153155endif
     
    325327
    326328
    327 ## Produce stylesheet for translating cross references (xref) to user manual
    328 # chapters and sections in the man pages and --help output.
     329## Emit rules to produce stylesheet for translating cross references (xref)
     330# to user manual chapters and sections in the man pages and --help output.
    329331#
    330332# Note! This requires processing UserManual.xml as a single document in order
     
    333335#       one.  This reduces the dependencies and recipies we require to build
    334336#       VBoxManage and the RTIsoMaker (w/ derivatives).
    335 $(VBOX_XML_XREF_TO_TEXT) + $(VBOX_XML_XREF_TO_TEXT).cat: \
    336                 $(VBOX_PATH_MANUAL_SRC)/docbook-refentry-link-replacement-xsl-gen.xsl \
    337                 $(addprefix $(VBOX_PATH_MANUAL_SRC)/en_US/,$(VBOX_MANUAL_XML_FILES)) \
    338                 $(VBOX_MANUAL_XML_FILES_COMMON) \
    339                 $(VBOX_XML_CATALOG) $(VBOX_XML_CATALOG_DOCBOOK) $(VBOX_XML_CATALOG_MANUAL) $(VBOX_XML_ENTITIES) \
    340                | $$(dir $$@)
    341         $(call MSG_L1,Creating stylesheet $@)
    342         $(QUIET)$(APPEND) -nt "$(VBOX_XML_XREF_TO_TEXT).cat" \
     337# $(evalcall2 def_vbox_xref_to_text)
     338# @param    1   Language code.
     339define def_vbox_xref_to_text
     340$$(VBOX_PATH_MANUAL_OUTBASE)/$(1)/xref-to-text.xsl \
     341+ $$(VBOX_PATH_MANUAL_OUTBASE)/$(1)/xref-to-text.xsl.cat: \
     342                $$(VBOX_PATH_MANUAL_SRC)/$(1)/docbook-refentry-link-replacement-xsl-gen.xsl \
     343                $$(addprefix $$(VBOX_PATH_MANUAL_SRC)/en_US/,$$(VBOX_MANUAL_XML_FILES)) \
     344                $$(VBOX_MANUAL_XML_FILES_COMMON) \
     345                $$(VBOX_XML_CATALOG) $$(VBOX_XML_CATALOG_DOCBOOK) $$(VBOX_XML_CATALOG_MANUAL) $$(VBOX_XML_ENTITIES) \
     346               | $$$$(dir $$$$@)
     347        $$(call MSG_L1,Creating stylesheet $$@)
     348        $$(QUIET)$$(APPEND) -nt "$$(VBOX_PATH_MANUAL_OUTBASE)/$(1)/xref-to-text.xsl.cat" \
    343349                '<?xml version="1.0"?>' \
    344350                '<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">' \
    345351                '<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">' \
    346                 $(foreach x,user_VBoxManage_CommandsOverview.xml user_isomakercmd-man.xml $(addprefix user_,$(VBOX_MANUAL_XML_REFENTRY_FILES))\
    347                 ,'  <system systemId="$(VBOX_PATH_MANUAL_SRC)/en_US/$(x)" uri="file://$(VBOX_FILE_URL_MAYBE_SLASH)$(VBOX_PATH_MANUAL_SRC)/dummy-sect1.xml"/>') \
    348                 '  <nextCatalog catalog="file://$(VBOX_FILE_URL_MAYBE_SLASH)$(VBOX_XML_CATALOG)"/>' \
     352                $$(foreach x,user_VBoxManage_CommandsOverview.xml user_isomakercmd-man.xml $$(addprefix user_,$$(VBOX_MANUAL_XML_REFENTRY_FILES))\
     353                ,'  <system systemId="$$(VBOX_PATH_MANUAL_SRC)/en_US/$$(x)" uri="file://$$(VBOX_FILE_URL_MAYBE_SLASH)$$(VBOX_PATH_MANUAL_SRC)/dummy-sect1.xml"/>') \
     354                '  <nextCatalog catalog="file://$$(VBOX_FILE_URL_MAYBE_SLASH)$$(VBOX_XML_CATALOG)"/>' \
    349355                '</catalog>'
    350         $(QUIET)$(call VBOX_XSLTPROC_WITH_CAT, -E "XML_CATALOG_FILES=$(VBOX_XML_XREF_TO_TEXT).cat") \
    351                 --stringparam 'g_sMode' 'first' --output "$@" "$<" $(filter %UserManual.xml,$^)
    352         $(foreach x, $(VBOX_MANUAL_XML_REFENTRY_FILES)\
    353                 ,$(NLTAB)$(QUIET)$(call VBOX_XSLTPROC_WITH_CAT, -ato "$@") --stringparam 'g_sMode' 'append' \
    354                         "$<" "$(VBOX_PATH_MANUAL_SRC)/en_US/$(x)")
    355         $(QUIET)$(APPEND) -n "$@" '' '</xsl:stylesheet>'
     356        $$(QUIET)$$(call VBOX_XSLTPROC_WITH_CAT, -E "XML_CATALOG_FILES=$$(VBOX_PATH_MANUAL_OUTBASE)/xref-to-text$(1).xsl.cat") \
     357                --stringparam 'g_sMode' 'first' --output "$$@" "$$<" $$(filter %UserManual.xml,$$^)
     358        # Using en-US version as section and chapter names until user manual is translated as well
     359        $$(foreach x, $$(VBOX_MANUAL_XML_REFENTRY_FILES)\
     360                ,$$(NLTAB)$$(QUIET)$$(call VBOX_XSLTPROC_WITH_CAT, -ato "$$@") --stringparam 'g_sMode' 'append' \
     361                        "$$<" "$$(VBOX_PATH_MANUAL_SRC)/en_US/$$(x)")
     362        $$(QUIET)$$(APPEND) -n "$$@" '' '</xsl:stylesheet>'
     363endef
     364# generate rules for $(VBOX_XML_XREF_TO_TEXT)
     365$(evalcall2 def_vbox_xref_to_text,)
    356366
    357367#
  • trunk/doc/manual/docbook-refentry-link-replacement-xsl-gen.xsl

    r92084 r92824  
    2525
    2626<xsl:param name="g_sMode" select="not-specified"/>
     27
     28  <!-- Translatable strings -->
     29  <xsl:variable name="sChapter" select="'chapter'"/>
     30  <xsl:variable name="sSection" select="'section'"/>
     31  <xsl:variable name="sOfManual" select="'of the user manual'"/>
     32  <xsl:variable name="sInManual" select="'in the user manual'"/>
     33
    2734
    2835<!-- Default operation is to supress output -->
     
    6774&lt;xsl:template match="xref[@linkend='</xsl:text>
    6875  <xsl:value-of select="../@id"/><xsl:text>']"&gt;
    69   &lt;xsl:text&gt;chapter </xsl:text><xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> &quot;</xsl:text>
     76  &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sChapter"/><xsl:text> </xsl:text>
     77  <xsl:value-of select="count(../preceding-sibling::chapter) + 1"/><xsl:text> &quot;</xsl:text>
    7078  <xsl:value-of select="normalize-space()"/>
    71   <xsl:text>&quot; in the user manual&lt;/xsl:text&gt;
     79  <xsl:text>&quot; </xsl:text><xsl:value-of select="$sInManual"/><xsl:text>&lt;/xsl:text&gt;
    7280&lt;/xsl:template&gt;
    7381</xsl:text>
     
    7886  <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
    7987  <xsl:value-of select="../@id"/><xsl:text>']"&gt;
    80   &lt;xsl:text&gt;section </xsl:text>
     88  &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
    8189  <xsl:value-of select="count(../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
    8290  <xsl:value-of select="count(../preceding-sibling::sect1) + 1"/>
    8391  <xsl:text> &quot;</xsl:text>
    84   <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
     92  <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
     93  <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
    8594&lt;/xsl:template&gt;
    8695</xsl:text>
     
    91100  <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
    92101  <xsl:value-of select="../@id"/><xsl:text>']"&gt;
    93   &lt;xsl:text&gt;section </xsl:text>
     102  &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
    94103  <xsl:value-of select="count(../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
    95104  <xsl:value-of select="count(../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
    96105  <xsl:value-of select="count(../preceding-sibling::sect2) + 1"/>
    97106  <xsl:text> &quot;</xsl:text>
    98   <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
     107  <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
     108  <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
    99109&lt;/xsl:template&gt;
    100110</xsl:text>
     
    105115  <xsl:text>&lt;xsl:template match="xref[@linkend='</xsl:text>
    106116  <xsl:value-of select="../@id"/><xsl:text>']"&gt;
    107   &lt;xsl:text&gt;section </xsl:text>
     117  &lt;xsl:text&gt;</xsl:text><xsl:value-of select="$sSection"/><xsl:text> </xsl:text>
    108118  <xsl:value-of select="count(../../../../preceding-sibling::chapter) + 1"/><xsl:text>.</xsl:text>
    109119  <xsl:value-of select="count(../../../preceding-sibling::sect1) + 1"/><xsl:text>.</xsl:text>
     
    111121  <xsl:value-of select="count(../preceding-sibling::sect3) + 1"/>
    112122  <xsl:text> &quot;</xsl:text>
    113   <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
     123  <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
     124  <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
    114125&lt;/xsl:template&gt;
    115126</xsl:text>
     
    121132  <xsl:value-of select="../@id"/><xsl:text>']"&gt;
    122133  &lt;xsl:text&gt;&quot;</xsl:text>
    123   <xsl:value-of select="normalize-space()"/><xsl:text>&quot; of the user manual&lt;/xsl:text&gt;
     134  <xsl:value-of select="normalize-space()"/><xsl:text>&quot; </xsl:text>
     135  <xsl:value-of select="$sOfManual"/><xsl:text>&lt;/xsl:text&gt;
    124136&lt;/xsl:template&gt;
    125137</xsl:text>
  • trunk/doc/manual/docbook-refentry-to-C-help.xsl

    r91006 r92824  
    4040  <!-- Sub-command style command (true) or single command (false). -->
    4141  <xsl:variable name="g_fSubCommands" select="not(not(//refsect2[@id]))" />
     42
     43  <!-- Translatable strings -->
     44  <xsl:variable name="sUsage"           select="'Usage'"/>
     45  <xsl:variable name="sUsageUnderscore" select="'====='"/>
     46
    4247
    4348  <!-- Default action, do nothing. -->
     
    125130    <xsl:text>
    126131    {   RTMSGREFENTRYSTR_SCOPE_GLOBAL,
    127         "Usage" },
     132        "</xsl:text><xsl:value-of select="$sUsage"/><xsl:text>" },
    128133    {   RTMSGREFENTRYSTR_SCOPE_SAME,
    129         "=====" },</xsl:text>
     134        "</xsl:text><xsl:value-of select="$sUsageUnderscore"/><xsl:text>" },</xsl:text>
    130135        <xsl:apply-templates select="./refsynopsisdiv/node()"/>
    131136
  • trunk/src/VBox/Frontends/VBoxManage/Makefile.kmk

    r92403 r92824  
    9696        VBoxManageHelp.cpp \
    9797        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.cpp \
     98        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_en_US.cpp \
    9899        VBoxManageHostonly.cpp \
    99100        VBoxManageInfo.cpp \
     
    117118
    118119ifdef VBOX_WITH_VBOXMANAGE_NLS
     120 VBOX_PATH_VBOXMANAGE_SRC := $(PATH_SUB_CURRENT)
     121 include $(PATH_SUB_CURRENT)/nls/ApprovedLanguages.kmk
     122
    119123 VBoxManage_DEFS      += VBOX_WITH_VBOXMANAGE_NLS
    120124 VBoxManage_INCS      += \
     
    123127        $(PATH_ROOT)/src/VBox/Main/src-all/VirtualBoxTranslator.cpp \
    124128        $(PATH_ROOT)/src/VBox/Main/src-all/QMTranslatorImpl.cpp \
    125         $(PATH_ROOT)/src/VBox/Main/src-all/GlobalStatusConversion.cpp
     129        $(PATH_ROOT)/src/VBox/Main/src-all/GlobalStatusConversion.cpp \
     130
     131#       $(addsuffix /VBoxManageBuiltInHelp.cpp,$(addprefix $(VBoxManage_0_OUTDIR)/,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES)))
     132#VBoxManage_INTERMEDIATES += \
     133#       $(addsuffix /VBoxManageBuiltInHelp.h,$(addprefix $(VBoxManage_0_OUTDIR)/,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES)))
    126134
    127135# define qt5 tools for translation
    128136 USES += qt5
    129 
    130  VBOX_PATH_VBOXMANAGE_SRC := $(PATH_SUB_CURRENT)
    131  include $(PATH_SUB_CURRENT)/nls/ApprovedLanguages.kmk
    132137
    133138 PROGRAMS += VBoxManageNls
     
    208213
    209214VBoxManage_CLEAN += \
     215        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_en_US.cpp \
     216        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_en_US.cpp.ts \
    210217        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.cpp \
    211218        $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.cpp.ts \
     
    214221       $(addprefix $(VBoxManage_0_OUTDIR)/,$(filter man_VBoxManage-%,$(VBOX_MANUAL_XML_REFENTRY_FILES)))
    215222
    216 
    217 
    218223# Preprocess the xml files, applying remarks.
    219224$(foreach file,$(filter man_VBoxManage-%,$(VBOX_MANUAL_XML_REFENTRY_FILES)) \
    220 , $(evalcall2 def_vbox_refentry_preprocess_for_manpage,$(VBoxManage_0_OUTDIR),$(file),$(VBOX_PATH_MANUAL_SRC)/en_US/$(file),replace-xrefs))
    221 
     225, $(evalcall2 def_vbox_refentry_preprocess_for_manpage,$(VBoxManage_0_OUTDIR),$(file), \
     226        $(VBOX_PATH_MANUAL_SRC)/en_US/$(file),replace-xrefs))
     227
     228
     229##
     230# Emits rules for generating cpp files from man pages.
     231#
     232# $(evalcall2 def_vbox_man_generate_cpp_help)
     233# @param    1    Folder with preprocessed man_VBoxManage_* files
     234# @param    2    language code.
     235define def_vbox_man_generate_cpp_help
     236ifneq ($(2),en_US)
     237VBOX_DOCBOOK_REFENTRY_TO_C_HELP_$(2) = $(VBOX_PATH_MANUAL_SRC)/$(2)/docbook-refentry-to-C-help.xsl
     238else
     239VBOX_DOCBOOK_REFENTRY_TO_C_HELP_$(2) = $(VBOX_DOCBOOK_REFENTRY_TO_C_HELP)
     240endif
     241$$(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_$(2).cpp.ts \
     242+| $$(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_$(2).cpp: \
     243                $$(VBOX_DOCBOOK_REFENTRY_TO_C_HELP_$(2)) \
     244                $$(VBOX_DOCBOOK_REFENTRY_TO_C_HELP) \
     245                $$(addprefix $(1)/,$$(filter man_VBoxManage-%,$$(VBOX_MANUAL_XML_REFENTRY_FILES))) \
     246                $$(VBOX_XML_CATALOG) $$(VBOX_XML_CATALOG_DOCBOOK) $$(MAKEFILE) | $$$$(dir $$$$@)
     247        $$(call MSG_TOOL,xsltproc $$(notdir $$(firstword $$(filter %.xsl,$$^))),,$$(filter %.xml,$$^),$$(patsubst %.ts,%,$$@))
     248        $$(QUIET)$$(APPEND) -tn "$$@" \
     249                '/* Autogenerated by $$<, do not edit! */' \
     250                '' \
     251                '#include "VBoxManageBuiltInHelp.h"' \
     252                '' \
     253                'RT_C_DECLS_BEGIN' \
     254                '/* make next variables visible outside the module */' \
     255                'extern PCRTMSGREFENTRY g_apHelpEntries_$(2)[];' \
     256                'extern const uint32_t  g_cHelpEntries_$(2);' \
     257                'RT_C_DECLS_END' \
     258                '' \
     259        $$(foreach refentry,$$(filter %.xml,$$^) \
     260        ,$$(NLTAB)$$(QUIET)$$(call VBOX_XSLTPROC_WITH_CAT, -a+to "$$@") \
     261                 --path '$(VBOX_PATH_MANUAL_SRC)/$(2) $(VBOX_PATH_MANUAL_SRC)/en_US' $$< $$(refentry))
     262        $$(QUIET)$$(APPEND) -n "$$@" \
     263                '' \
     264                'PCRTMSGREFENTRY     g_apHelpEntries_$(2)[] =' \
     265                '{'
     266        $$(foreach refentry,$$(filter %.xml,$$^) \
     267                ,$$(NLTAB)$$(QUIET)$$(APPEND) -n "$$@" \
     268                '    &g_$$(subst -,_,$$(tolower $$(patsubst man_%,%,$$(notdir $$(basename $$(refentry)))))),')
     269        $$(QUIET)$$(APPEND) -n "$$@" \
     270                '};' \
     271                '' \
     272                'const uint32_t g_cHelpEntries_$(2) = RT_ELEMENTS(g_apHelpEntries_$(2));' \
     273                ''
     274        $$(QUIET)$$(CP) --changed -- "$$@" "$$(patsubst %.ts,%,$$@)"
     275endef
     276# The above APPEND stuff trigger some kind of problem on some boxes when not split up...
     277# update: Fixed in SVN (strcpy -> memmove in new_job(), job.c - r2591). Just need to rebuild all platforms.
    222278
    223279# Generate the .cpp file.
     280$(evalcall2 def_vbox_man_generate_cpp_help, $(VBoxManage_0_OUTDIR),en_US)
     281
     282
     283# generate built-in for the english only
    224284$(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.cpp.ts \
    225285+| $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.cpp: \
    226                 $(VBOX_DOCBOOK_REFENTRY_TO_C_HELP) \
    227                 $(addprefix $(VBoxManage_0_OUTDIR)/,$(filter man_VBoxManage-%,$(VBOX_MANUAL_XML_REFENTRY_FILES))) \
    228                 $(VBOX_XML_CATALOG) $(VBOX_XML_CATALOG_DOCBOOK) $(MAKEFILE) | $$(dir $$@)
    229         $(call MSG_TOOL,xsltproc $(notdir $(firstword $(filter %.xsl,$^))),,$(filter %.xml,$^),$(patsubst %.ts,%,$@))
     286                $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_en_US.cpp \
     287                $(foreach lang,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES), $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_$(lang).cpp ) \
     288                $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp.h
    230289        $(QUIET)$(APPEND) -tn "$@" \
    231                 '/* Autogenerated by $<, do not edit! */' \
     290                '/* Autogenerated, do not edit! */' \
    232291                '' \
    233292                '#include "VBoxManageBuiltInHelp.h"' \
    234                 ''
    235         $(foreach refentry,$(filter %.xml,$^) \
    236         ,$(NLTAB)$(QUIET)$(call VBOX_XSLTPROC_WITH_CAT, -a+to "$@") $< $(refentry))
     293                '' \
     294                'RT_C_DECLS_BEGIN' \
     295                '' \
     296                'extern PCRTMSGREFENTRY g_apHelpEntries_en_US[];' \
     297                'extern const uint32_t  g_cHelpEntries_en_US;'
     298ifdef VBOX_WITH_VBOXMANAGE_NLS
     299        $(foreach lang,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     300        ,$(NLTAB)$(QUIET)$(APPEND) -n "$@" \
     301                '' \
     302                'extern PCRTMSGREFENTRY g_apHelpEntries_$(lang)[];' \
     303                'extern const uint32_t  g_cHelpEntries_$(lang);')
     304endif
    237305        $(QUIET)$(APPEND) -n "$@" \
    238         '' \
    239                 'PCRTMSGREFENTRY     g_apHelpEntries[] =' \
    240                 '{'
    241         $(foreach refentry,$(filter %.xml,$^) \
    242                 ,$(NLTAB)$(QUIET)$(APPEND) -n "$@" \
    243                 '    &g_$(subst -,_,$(tolower $(patsubst man_%,%,$(notdir $(basename $(refentry)))))),')
     306                '' \
     307                'RT_C_DECLS_END' \
     308                '' \
     309                'HELP_LANG_ENTRY g_apHelpLangEntries[] = ' \
     310                '{' \
     311                '    {"en_US", 5, &g_apHelpEntries_en_US[0], g_cHelpEntries_en_US},'
     312ifdef VBOX_WITH_VBOXMANAGE_NLS
     313        $(foreach lang,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     314        ,$(NLTAB)$(QUIET)$(APPEND) "$@" '    {"$(lang)", $(length $(lang)), &g_apHelpEntries_$(lang)[0], g_cHelpEntries_$(lang)},' )
     315endif
    244316        $(QUIET)$(APPEND) -n "$@" \
    245317                '};' \
    246                 'const uint32_t g_cHelpEntries = RT_ELEMENTS(g_apHelpEntries);' \
    247                ''
     318                '' \
     319                'const uint32_t g_cHelpLangEntries = RT_ELEMENTS(g_apHelpLangEntries);' \
     320                '' \
     321                'void * volatile g_pHelpLangEntry = (void *)&g_apHelpLangEntries[0];'\
     322                ''
    248323        $(QUIET)$(CP) --changed -- "$@" "$(patsubst %.ts,%,$@)"
    249 # The above APPEND stuff trigger some kind of problem on some boxes when not split up...
    250 # update: Fixed in SVN (strcpy -> memmove in new_job(), job.c - r2591). Just need to rebuild all platforms.
    251324
    252325
     
    259332        $(QUIET)$(APPEND) -tn "$@" \
    260333                '/* Autogenerated by $<, do not edit! */' \
    261                '' \
    262                '#ifndef ___VBoxManageBuiltInHelp_h___' \
    263                '#define ___VBoxManageBuiltInHelp_h___' \
    264                '' \
    265                '#include <iprt/message.h>' \
    266                '' \
    267                'RT_C_DECLS_BEGIN' \
    268                '' \
    269                'typedef enum HELP_CMD_VBOXMANAGE' \
    270                '{' \
    271                '    HELP_CMD_VBOXMANAGE_INVALID = 0,'
     334                '' \
     335                '#ifndef ___VBoxManageBuiltInHelp_h___' \
     336                '#define ___VBoxManageBuiltInHelp_h___' \
     337                '' \
     338                '#include <iprt/message.h>' \
     339                '' \
     340                'RT_C_DECLS_BEGIN' \
     341                '' \
     342                'typedef enum HELP_CMD_VBOXMANAGE' \
     343                '{' \
     344                '    HELP_CMD_VBOXMANAGE_INVALID = 0,'
    272345        $(foreach refentry,$(filter %.xml,$^) \
    273346        ,$(NLTAB)$(QUIET)$(call VBOX_XSLTPROC_WITH_CAT, -a+to "$@") \
     
    281354        $(QUIET)$(APPEND) -n "$@" \
    282355                '' \
    283                 'extern PCRTMSGREFENTRY g_apHelpEntries[];' \
    284                 'extern const uint32_t  g_cHelpEntries;' \
    285                 '' \
    286                'RT_C_DECLS_END' \
     356                'typedef struct HELP_LANG_ENTRY' \
     357                '{' \
     358                '    const char      *pszLang;' \
     359                '        size_t           cbLang;' \
     360                '    PCRTMSGREFENTRY *papHelpEntries;' \
     361                '    const uint32_t   cHelpEntries;' \
     362                '} HELP_LANG_ENTRY;' \
     363                '' \
     364                'extern HELP_LANG_ENTRY g_apHelpLangEntries[];' \
     365                'extern const uint32_t  g_cHelpLangEntries;' \
     366                '' \
     367                'extern void * volatile g_pHelpLangEntry;' \
     368                '' \
     369                'RT_C_DECLS_END' \
    287370                '' \
    288371                '#endif' \
    289                ''
     372                ''
    290373        $(QUIET)$(CP) --changed -- "$@" "$(patsubst %.ts,%,$@)"
    291374
     375ifdef VBOX_WITH_VBOXMANAGE_NLS
     376 VBoxManage_BLDDIRS += \
     377        $(addprefix $(VBoxManage_0_OUTDIR)/,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES))
     378
     379 VBoxManage_SOURCES += \
     380        $(foreach lang, $(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     381        , $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_$(lang).cpp)
     382
     383 VBoxManage_CLEAN += \
     384        $(addsuffix .cpp,$(addprefix $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES))) \
     385        $(addsuffix .cpp.ts,$(addprefix $(VBoxManage_0_OUTDIR)/VBoxManageBuiltInHelp_,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES))) \
     386        $(foreach file, $(filter man_VBoxManage-%,$(VBOX_MANUAL_XML_REFENTRY_FILES)) \
     387        , $(addsuffix /$(file),$(addprefix $(VBoxManage_0_OUTDIR)/,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES))))
     388
     389 # Preprocess the xml files, applying remarks.
     390 $(foreach lang, $(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     391 , $(foreach file,$(filter man_VBoxManage-%,$(VBOX_MANUAL_XML_REFENTRY_FILES)) \
     392   , $(evalcall2 def_vbox_refentry_preprocess_for_manpage,$(VBoxManage_0_OUTDIR)/$(lang),$(file) \
     393       ,$(VBOX_PATH_MANUAL_SRC)/$(lang)/$(file),replace-xrefs,$(lang))))
     394
     395 # Generate the .cpp file.
     396 $(foreach lang, $(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     397 , $(evalcall2 def_vbox_man_generate_cpp_help,$(VBoxManage_0_OUTDIR)/$(lang),$(lang)))
     398
     399 # Ensure $(lang) subfolder in the $(VBOX_PATH_MANUAL_OUTBASE) is created (for section names file)
     400 BLDDIRS += $(addprefix $(VBOX_PATH_MANUAL_OUTBASE)/,$(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES))
     401
     402 # Generate sections names file for $(lang)
     403 $(foreach lang, $(VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES) \
     404 , $(evalcall2 def_vbox_xref_to_text,$(lang)))
     405
     406endif
    292407
    293408include $(FILE_KBUILD_SUB_FOOTER)
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r92538 r92824  
    9191DECLARE_TRANSLATION_CONTEXT(VBoxManage);
    9292
     93static void setBuiltInHelpLanguage(const char *pszLang);
     94
    9395#ifdef VBOX_WITH_VBOXMANAGE_NLS
    9496/* listener class for language updates */
     
    145147                            LogFunc(("New language ID: %s\n", strLanguageId.c_str()));
    146148                            pTranslator->i_loadLanguage(strLanguageId.c_str());
     149                            setBuiltInHelpLanguage(strLanguageId.c_str());
    147150                        }
    148151                        catch (std::bad_alloc &)
     
    260263};
    261264
     265
     266static void setBuiltInHelpLanguage(const char *pszLang)
     267{
     268#ifdef VBOX_WITH_VBOXMANAGE_NLS
     269    if (pszLang == NULL || pszLang[0] == 0 || pszLang[0] == 'C' && pszLang[1] == 0)
     270        pszLang = "en_US";
     271    void *pHelpLangEntry = NULL;
     272    /* find language entry matching exactly pszLang */
     273    for (uint32_t i = 0; i < g_cHelpLangEntries; i++)
     274    {
     275        if (strcmp(g_apHelpLangEntries[i].pszLang, pszLang) == 0)
     276        {
     277            pHelpLangEntry = (void *)&g_apHelpLangEntries[i];
     278            break;
     279        }
     280    }
     281    /* find first entry containing language specified if pszLang contains only language */
     282    if (pHelpLangEntry == NULL)
     283    {
     284        size_t cbLang = strlen(pszLang);
     285        for (uint32_t i = 0; i < g_cHelpLangEntries; i++)
     286        {
     287            if (   cbLang < g_apHelpLangEntries[i].cbLang
     288                && memcmp(g_apHelpLangEntries[i].pszLang, pszLang, cbLang) == 0)
     289            {
     290                pHelpLangEntry = (void *)&g_apHelpLangEntries[i];
     291                break;
     292            }
     293        }
     294    }
     295    /* set to en_US (i.e. untranslated) if not found */
     296    if (pHelpLangEntry == NULL)
     297        pHelpLangEntry = (void *)&g_apHelpLangEntries[0];
     298
     299     ASMAtomicWritePtrVoid(&g_pHelpLangEntry, pHelpLangEntry);
     300#endif
     301}
     302
     303
    262304/**
    263305 * Looks up a command by name.
     
    549591            {
    550592                vrc = pTranslator->i_loadLanguage(NULL);
    551                 if (RT_FAILURE(vrc))
     593                if (RT_SUCCESS(vrc))
     594                {
     595                    com::Utf8Str strLang = pTranslator->language();
     596                    setBuiltInHelpLanguage(strLang.c_str());
     597                }
     598                else
    552599                    LogRelFunc(("Load language failed: %Rrc\n", vrc));
    553600            }
     
    765812            {
    766813                HRESULT hrc1 = pTranslator->loadLanguage(virtualBox);
    767                 if (FAILED(hrc1))
     814                if (SUCCEEDED(hrc1))
     815                {
     816                    com::Utf8Str strLang = pTranslator->language();
     817                    setBuiltInHelpLanguage(strLang.c_str());
     818                }
     819                else
    768820                {
    769821                    /* Just log and ignore the language error */
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManageHelp.cpp

    r92538 r92824  
    2222#include <VBox/version.h>
    2323
     24#include <iprt/asm.h>
    2425#include <iprt/buildconfig.h>
    2526#include <iprt/ctype.h>
     
    8081
    8182
     83/**
     84 * Takes first char and make it uppercase.
     85 *
     86 * @returns pointer to string starting from next char.
     87 * @param   pszSrc            Source string.
     88 * @param   pszFirstCharBuffer Pointer to buffer to place first char uppercase
     89 */
     90static const char *firstCharUppercase(const char *pszSrc, char *pszFirstCharBuffer)
     91{
     92    RTUNICP Cp;
     93    RTStrGetCpEx(&pszSrc, &Cp);
     94    char *pszBuffer = RTStrPutCp(pszFirstCharBuffer, Cp);
     95    RTStrToUpper(pszBuffer);
     96    pszBuffer[0] = 0;
     97    return pszSrc;
     98}
    8299
    83100
     
    96113    uint32_t cPendingBlankLines = 0;
    97114    uint32_t cFound = 0;
    98     for (uint32_t i = 0; i < g_cHelpEntries; i++)
    99     {
    100         PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
    101         if (pHelp->idInternal == (int64_t)enmCommand)
     115#ifdef VBOX_WITH_VBOXMANAGE_NLS
     116    HELP_LANG_ENTRY *pHelpLangEntry[2] = {ASMAtomicReadPtrT(&g_pHelpLangEntry, HELP_LANG_ENTRY *), &g_apHelpLangEntries[0] };
     117#else
     118    HELP_LANG_ENTRY *pHelpLangEntry[1] = {(HELP_LANG_ENTRY *)g_pHelpLangEntry};
     119#endif
     120    /* Try to find translated, then untranslated */
     121    for (int k = 0; k < RT_ELEMENTS(pHelpLangEntry) && cFound == 0; k++)
     122    {
     123        /* skip if english is used */
     124        if (k > 0 && pHelpLangEntry[k] == pHelpLangEntry[0])
     125            break;
     126        for (uint32_t i = 0; i < pHelpLangEntry[k]->cHelpEntries; i++)
    102127        {
    103             cFound++;
    104             if (cFound == 1)
     128            PCRTMSGREFENTRY pHelp = pHelpLangEntry[k]->papHelpEntries[i];
     129            if (pHelp->idInternal == (int64_t)enmCommand)
    105130            {
    106                 if (fSubcommandScope == RTMSGREFENTRYSTR_SCOPE_GLOBAL)
    107                     RTStrmPrintf(pStrm, Help::tr("Usage - %c%s:\n"), RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
    108                 else
    109                     RTStrmPrintf(pStrm, Help::tr("Usage:\n"));
     131                cFound++;
     132                if (cFound == 1)
     133                {
     134                    if (fSubcommandScope == RTMSGREFENTRYSTR_SCOPE_GLOBAL)
     135                    {
     136                        char szFirstChar[16] = {0};
     137                        const char *pszNext = firstCharUppercase(pHelp->pszBrief, szFirstChar);
     138                        RTStrmPrintf(pStrm, Help::tr("Usage - %s%s:\n"), szFirstChar, pszNext);
     139                    }
     140                    else
     141                        RTStrmPrintf(pStrm, Help::tr("Usage:\n"));
     142                }
     143                RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, fSubcommandScope, &cPendingBlankLines, &cLinesWritten);
     144                if (!cPendingBlankLines)
     145                    cPendingBlankLines = 1;
    110146            }
    111             RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, fSubcommandScope, &cPendingBlankLines, &cLinesWritten);
    112             if (!cPendingBlankLines)
    113                 cPendingBlankLines = 1;
    114147        }
    115148    }
     
    142175    uint32_t cPendingBlankLines = 0;
    143176    uint32_t cFound = 0;
    144     for (uint32_t i = 0; i < g_cHelpEntries; i++)
    145     {
    146         PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
    147         if (   pHelp->idInternal == (int64_t)enmCommand
    148             || enmCommand == HELP_CMD_VBOXMANAGE_INVALID)
     177#ifdef VBOX_WITH_VBOXMANAGE_NLS
     178    HELP_LANG_ENTRY *pHelpLangEntry[2] = {ASMAtomicReadPtrT(&g_pHelpLangEntry, HELP_LANG_ENTRY *), &g_apHelpLangEntries[0] };
     179#else
     180    HELP_LANG_ENTRY *pHelpLangEntry[1] = {(HELP_LANG_ENTRY *)g_pHelpLangEntry};
     181#endif
     182    /* Try to find translated, then untranslated */
     183    for (int k = 0; k < RT_ELEMENTS(pHelpLangEntry) && cFound == 0; k++)
     184    {
     185        /* skip if english is used */
     186        if (k > 0 && pHelpLangEntry[k] == pHelpLangEntry[0])
     187            break;
     188        for (uint32_t i = 0; i < pHelpLangEntry[k]->cHelpEntries; i++)
    149189        {
    150             cFound++;
    151             RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Help, fSubcommandScope, &cPendingBlankLines, NULL /*pcLinesWritten*/);
    152             if (cPendingBlankLines < 2)
    153                 cPendingBlankLines = 2;
     190            PCRTMSGREFENTRY pHelp = pHelpLangEntry[k]->papHelpEntries[i];
     191
     192            if (   pHelp->idInternal == (int64_t)enmCommand
     193                || enmCommand == HELP_CMD_VBOXMANAGE_INVALID)
     194            {
     195                cFound++;
     196                RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Help, fSubcommandScope, &cPendingBlankLines, NULL /*pcLinesWritten*/);
     197                if (cPendingBlankLines < 2)
     198                    cPendingBlankLines = 2;
     199            }
    154200        }
    155201    }
     
    9891035    {
    9901036        uint32_t cPendingBlankLines = 0;
    991         for (uint32_t i = 0; i < g_cHelpEntries; i++)
     1037#ifdef VBOX_WITH_VBOXMANAGE_NLS
     1038        HELP_LANG_ENTRY *pHelpLangEntry = ASMAtomicReadPtrT(&g_pHelpLangEntry, HELP_LANG_ENTRY *);
     1039#else
     1040        HELP_LANG_ENTRY *pHelpLangEntry = (HELP_LANG_ENTRY *)g_pHelpLangEntry;
     1041#endif
     1042        for (uint32_t i = 0; i < pHelpLangEntry->cHelpEntries; i++)
    9921043        {
    993             PCRTMSGREFENTRY pHelp = g_apHelpEntries[i];
     1044            PCRTMSGREFENTRY pHelp = pHelpLangEntry->papHelpEntries[i];
     1045
    9941046            while (cPendingBlankLines-- > 0)
    9951047                RTStrmPutCh(pStrm, '\n');
    996             RTStrmPrintf(pStrm, " %c%s:\n", RT_C_TO_UPPER(pHelp->pszBrief[0]), pHelp->pszBrief + 1);
     1048            char szFirstChar[16] = {0};
     1049            const char *pszNext = firstCharUppercase(pHelp->pszBrief, szFirstChar);
     1050            RTStrmPrintf(pStrm, " %s%s:\n", szFirstChar, pszNext);
    9971051            cPendingBlankLines = 0;
    9981052            RTMsgRefEntryPrintStringTable(pStrm, &pHelp->Synopsis, RTMSGREFENTRYSTR_SCOPE_GLOBAL,
    999                                           &cPendingBlankLines, NULL /*pcLinesWritten*/);
     1053                                        &cPendingBlankLines, NULL /*pcLinesWritten*/);
    10001054            cPendingBlankLines = RT_MAX(cPendingBlankLines, 1);
    10011055        }
  • trunk/src/VBox/Frontends/VBoxManage/nls/ApprovedLanguages.kmk

    r92594 r92824  
    1919VBOX_APPROVED_VBOXMANAGE_LANGUAGES := \
    2020        ru
     21
     22# The list of approved VBoxManage language codes for built-in docbook
     23# help. Order matters for codes in the case of a language used in
     24# multiple countries. The language code used when no country is
     25# specified should be placed before other codes with the same language.
     26# For example: if en_US, en_UK and en_AU are approved the en_US should
     27# be placed before others allowing en_US to be used when the user
     28# specifies "en" as the desired language.
     29VBOX_APPROVED_VBOXMANAGE_DOCBOOK_LANGUAGES :=
  • trunk/src/VBox/Frontends/VBoxManage/nls/VBoxManageNls_ru.ts

    r92603 r92824  
    55505550    <message>
    55515551        <location filename="../VBoxManageHelp.cpp" line="107"/>
    5552         <source>Usage - %c%s:
    5553 </source>
    5554         <translation>Использование - %c%s:
     5552        <source>Usage - %s%s:
     5553</source>
     5554        <translation>Использование - %s%s:
    55555555</translation>
    55565556    </message>
  • trunk/src/VBox/Main/include/VirtualBoxTranslator.h

    r92068 r92824  
    108108    static int32_t initCritSect();
    109109
     110    com::Utf8Str language();
     111
    110112private:
    111113    static RTCRITSECTRW s_instanceRwLock;
  • trunk/src/VBox/Main/src-all/VirtualBoxTranslator.cpp

    r92145 r92824  
    226226
    227227
     228com::Utf8Str VirtualBoxTranslator::language()
     229{
     230    AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
     231
     232    return m_strLanguage;
     233}
     234
     235
    228236int VirtualBoxTranslator::i_loadLanguage(const char *pszLang)
    229237{
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette