Additional non .NET languages

Topics: Developer Forum, User Forum
Jan 9, 2013 at 4:16 PM

Hello,

First of all - thank you for maintaining such a great project!

I’m building a set of documentation for a WCF service, where I need to provide sample code in a few non .NET languages, such as PHP and Java.

The works, but it renders, below the main languages tab.

Is there a way:

1. Specify an additional language ?
2.  Add this language to the grouped languages, as described in http://shfb.codeplex.com/discussions/354300 ?

I’m using VS2010 presentation style and HTML output.

 

Thank you

Coordinator
Jan 9, 2013 at 8:01 PM

I haven't dug too deeply into how the VS2010 style groups the languages.  I do know that there are common templates it calls to get the language ID and title (see VS2010\transforms\codeTemplates.xsl) so you'd have to update them to include the new languages as well as add a couple of new resource items to represent the titles.  That along with the info in the other thread may be all you need.

Eric

 

Jan 9, 2013 at 9:39 PM

Eric, thank you for the prompt response.

Here is what I did:

1. \Presentation\vs2010\Branding\ps-codesnippet.xslt

 

  <xsl:variable name="groupedLanguages">
    <value>C#</value>
    <value>Visual Basic</value>
    <value>PHP</value>
  </xsl:variable>



2.  \Presentation\vs2010\Content\shared_content.xml and \Presentation\vs2010\Content\shared_content_mshc.xml:

<!-- devlang -->
<item id="devlang_VisualBasic">Visual Basic</item>
...
<item id="devlang_PHP">PHP</item>

  

3. \Presentation\vs2010\transforms\codeTemplates.xsl:

<xsl:template name="t_codeLang">
  <xsl:param name="p_codeLang"/>
  <xsl:variable name="v_codeLangLC"
                select="translate($p_codeLang,$g_allUpperCaseLetters,$g_allLowerCaseLetters)"/>
  <xsl:choose>
    <xsl:when test="$v_codeLangLC = 'vbs' or $v_codeLangLC = 'vbscript'">
      <xsl:text>VBScript</xsl:text>
    </xsl:when>
     .....	
    <xsl:when test="$v_codeLangLC = 'PHP'">
      <xsl:text>PHP</xsl:text>
    </xsl:when>
    <xsl:when test="$v_codeLangLC = 'none'">
      <xsl:value-of select="$v_codeLangLC"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:text>other</xsl:text>
    </xsl:otherwise>
  </xsl:choose>
</xsl:template>

and

<xsl:template name="t_codeLangName">
  <xsl:param name="p_codeLang"/>
  <xsl:variable name="v_codeLangUnique">
    <xsl:call-template name="t_codeLang">
      <xsl:with-param name="p_codeLang"
                      select="$p_codeLang"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="$v_codeLangUnique = 'VBScript'">
      <xsl:text>VBScript</xsl:text>
    </xsl:when>
    ...
    <xsl:when test="$v_codeLangUnique = 'PHP'">
      <xsl:text>PHP</xsl:text>
    </xsl:when>
    <xsl:otherwise/>
  </xsl:choose>
</xsl:template>

and

<xsl:template name="t_codeLangTitleId">
  <xsl:param name="p_codeLang"/>
  <xsl:variable name="v_codeLangUnique">
    <xsl:call-template name="t_codeLang">
      <xsl:with-param name="p_codeLang"
                      select="$p_codeLang"/>
    </xsl:call-template>
  </xsl:variable>
  <xsl:choose>
    <xsl:when test="$v_codeLangUnique = 'VisualBasic'" >
      <xsl:value-of select="'devlang_VisualBasic'"/>
    </xsl:when>
     ....
    <xsl:when test="$v_codeLangUnique = 'Python'">
      <xsl:value-of select="'devlang_Python'"/>
    </xsl:when>
    <xsl:when test="$v_codeLangUnique = 'PHP'">
      <xsl:value-of select="'devlang_PHP'"/>
    </xsl:when>
    <xsl:otherwise/>
  </xsl:choose>
</xsl:template>

and

<xsl:template name="t_mshelpCodelangAttributes">
  <xsl:param name="snippets"/>
  <xsl:for-each select="$snippets">

    <xsl:if test="not(@language=preceding::*/@language)">
      <xsl:variable name="v_codeLang">
        <xsl:choose>
          <xsl:when test="@language = 'VBScript' or @language = 'vbs'">
            <xsl:text>VBScript</xsl:text>
          </xsl:when>
         ....
          <xsl:when test="@language = 'PHP'">
            <xsl:text>PHP</xsl:text>
          </xsl:when>
          <xsl:otherwise>
            <xsl:text>other</xsl:text>
          </xsl:otherwise>
        </xsl:choose>
      </xsl:variable>
      <xsl:choose>
        <xsl:when test="$v_codeLang='other'"/>
        <!-- If $v_codeLang is already authored, then do nothing -->
        <xsl:when test="/document/metadata/attribute[@name='codelang']/text() = $v_codeLang"/>
        <xsl:otherwise>
          <xsl:call-template name="t_codeLangAttr">
            <xsl:with-param name="p_codeLang"
                            select="$v_codeLang"/>
          </xsl:call-template>
        </xsl:otherwise>
      </xsl:choose>
    </xsl:if>

  </xsl:for-each>
</xsl:template>
 

 

4. The comment section is defined as following:

<code language="PHP" >
.....
</code>



The section with PHP code still renders below C# and  VB and it does not have any title (e.g. - "PHP")

Am I missing something?

Thank you 

Ivan


 

Jan 9, 2013 at 10:05 PM

Eric,

 I have found the issue:

<xsl:when test="$v_codeLangLC = 'PHP'">
  <xsl:text>PHP</xsl:text>
</xsl:when>
should be
<xsl:when test="$v_codeLangLC = 'php'">
  <xsl:text>PHP</xsl:text>
</xsl:when>

 Thank you very much for pointing me to the right direction.


Ivan