Possible to use different languages?

Mar 4, 2009 at 11:33 AM
Edited Mar 4, 2009 at 12:01 PM
Is there a way to use different languages with BibWord? I want to use different e.g. <seperator_before_last> arguments in different languages. My first thought was to use another sourcetype (which I don't use) and use it for the other language, but I also found the language selection in the bibliography dialog in Word2007.

Is there anything that I can use for using different languages.

An example:
English:
Name1, and Name2

German:
Name1 und Name2

Thx,
Vertex

 

Coordinator
Mar 4, 2009 at 12:17 PM
No and although adding it would be pretty straightforward, I have my doubts regarding its functionality.

I prefer having a separate stylesheet for every language. The reason is the inconsistency of user/automatic input in Word. I'm a Dutch-speaking Belgian who bought his computer through a company in the French-speaking part of Belgium (meaning I got Vista Ultimate in French for which I downloaded the English language pack). On top of that, I'm using the multilanguage version of Office with the default language set to English-US. If I do not take real care on how I add a source, I end up with a bibliography in 3 different languages and 4 different punctuation schemes.

That said, if you wanted to implement multilanguage support into BibWord, it would be pretty easy. You could just extend each format element to have a lcid attribute and use that attribute's value to select the correct format string. You would have to add the selection procedure to the following xslt templates:
  • format-citation
  • format-footnote-citation
  • format-bibliography-as-paragraphs
  • format-bibliography-table-column
Mar 17, 2009 at 10:19 AM
Any example? I need this feature! But I don't know how to do.
Coordinator
Mar 17, 2009 at 10:54 AM

Do you really need multiple languages within the same bibliography?

If not, why not just create multiple styles and name them:

  • My style - English
  • My style - Dutch
  • My style - Spanish

Then you can select the style you want whenever you want it.

If you really want multiple languages support within one bibliography, you will have to extend BibWord yourself. My idea would be to change:

<column id="1">
    <halign>left</halign>
    <valign>top</valign>
    <format>{%Author:0|Editor:1%}{. <i>%Title|ShortTitle%</i>}{. Vol %Volume%}{. %Edition% edition}{. %City%}{: %Publisher%}{; %Year%}.</format>
</column>

into something along the following lines:

<column id="1">
    <halign>left</halign>
    <valign>top</valign>
    <format lcid='1033'>{%Author:0|Editor:1%}{. <i>%Title|ShortTitle%</i>}{. Vol %Volume%}{. %Edition% edition}{. %City%}{: %Publisher%}{; %Year%}.</format>
    <format lcid='3082'>{%Author:2|Editor:3%}{. <i>%Title|ShortTitle%</i>}{. Vol %Volume%}{. %Edition% editie}{. %City%}{: %Publisher%}{; %Year%}.</format>
</column>

By using different list sets to format names (0,1 vs 2,3), you can format the namelists in any language you want.

Then you will have to adjust the 4 functions above to select the correct format string. But if you have some xslt knowledge, that wouldn't be all that hard.

Mar 17, 2009 at 11:52 AM
Thanks! But I don't know how to get the LCID selected by the user. User can select the language in the bibliography dialog in Word2007.

    <!-- Get the format string. -->
    <xsl:variable name="format">
      <xsl:variable name="type" select="./b:Type"/>
      <xsl:variable name="sourcetype" select="./b:SourceType"/>
      <xsl:variable name="_LCID" select="./b:Locals/b:LCID"/>        <!-- Which one should I select? -->

      <xsl:choose>
        <!-- Go for the type element if available. -->
        <xsl:when test="string-length($type) > 0 and string-length(msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = $columnId]/format) > 0 ">
          <xsl:value-of select="msxsl:node-set($data)/bibliography/source[@type = $type]/column[@id = $columnId]/format[@LCID=$_LCID]"/>
        </xsl:when>
      </xsl:choose>
    </xsl:variable>

Mar 17, 2009 at 12:11 PM
The default Chicago style works very well in different language. But I cannot understand the style file...
Coordinator
Mar 17, 2009 at 12:11 PM

What you are selecting is part of the locals tree, something which BibWord does not use. I am actually surprised it still returns something at that depth. Anyway, you have to get the lcid directly from the source. So instead of:

<xsl:variable name="_LCID" select="./b:Locals/b:LCID"/>

you would need:

<xsl:variable name="_LCID" select="./b:LCID"/>

But this is the crazy thing, the multilanguage support of Word often results in the LCID being different for different entries without the user actually willing so from the start. As a result, their bibliography ends up in a bunch of languages with them freaking out on how to fix it. Because you have to admit it looks bad if the first entry looks like:

Doe and Burton

while the second one looks like:

Doe en Thompson

So unless you really need multilanguage support within the same style, this is error-prone for end-users.

Coordinator
Mar 17, 2009 at 12:14 PM
The default styles select their information from a hardcoded tree under b:Locals. Unfortunately, some terms are missing. Also, punctuation often differs between languages. And they are hardcoded, so they aren't really open to change.

Are you really needing multiple languages within the same bibliography?
Mar 17, 2009 at 1:13 PM
Thank you very much!
I really need this feature!
It works now!
Mar 18, 2009 at 8:51 PM
Just a note: I was also able to solve my problem.

Thx again for great help!
Vertex
Apr 4, 2009 at 2:20 PM
Hi Yves,

I translated the IEEE template to German. Do you want me to send it or upload it to the SVN?

Cheers,
Georg
Jul 30, 2009 at 7:31 PM

Yves,

 

could you explain me how you manage to adapt the style-templates to different languages? My computer keyboard and language settings are German, but I usually write in Portuguese. When I set the default Office language to Portuguese though, the bibliography still comes up in German, unless I modify the sources one by one from "default" to "Portuguese"...

 

thanks a lot,

Peter

Coordinator
Jul 31, 2009 at 5:08 PM

Peter,

What exactly are you trying to achieve with which style?

The ones coming with Word are multilingual in that they take the language setting of each source to decide on the display language. So yes, you would have to set the language specifically to Portuguese. Actually, if you give a language parameter to your bibliography, only the sources in that language will be displayed when using the Word styles.

Living in a country with two main languages (Dutch and French) and mostly writing in a third language (English), automatic language settings tend to make me want to throw out my laptop out of the window at least a few times a week. That's why BibWord can only handle one language (unless the changes described above are made). BibWord does not use any of the predefined language variables.

Jul 31, 2009 at 5:45 PM

thanks yves!

 

what I would like to achieve is that the bibliography of a given document adjusts to the language of the paper I am writing, not the the language set individually for each source. For example, when I translate a paper from German to Portuguese, I have to change all the sources one by one so that in the bibliography it doesn't say "Smith und Miller", but "Smith e Miller".

Coordinator
Jul 31, 2009 at 7:04 PM

BibWord styles are only in one language. They won't change when you change the language field of a source. When you want to use another language, you just have to select a style from the dropdown list which is in that language.

For the Word 2007 default styles you might want to try to see if you can change the locale of the bibliography to fit your needs. Put your mouse on the bibliography, right click and select "Edit Field...". A window will popup and in it, you will see something like "BIBLIOGRAPHY \l 2070". The value after the "\l" decides on the language of the bibliography. A full list of LCID values can be found at http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx. You should use the decimal numbers (LCID Dec column). Change that value to the one in which language you want your bibliography displayed. Afterwards, right click again on your bibliography and select "Update Field" to see the change in language.

Note that the value behind the "\l" parameter is only used for sources with their language set to "Default" (LCID = 0). If you set your source to a specific language, then that language will be used to format that one source in your bibliography.

Jul 31, 2009 at 7:53 PM

Great, that actually works for the bibliography...

 

But the problem now is that if I set my sources to "default language", than the citation appears in the wrong format (e.g. "S." instead of "p." for the page number). Is there a way I could change this "default language" for a given document? Because if I change the default language of all the sources cited, than I end up with the problem that your trick doesn't work for the bibliography anymore...

Coordinator
Aug 1, 2009 at 9:56 AM

The same "\l" parameter is also available for citations. By default, Word assigns a value to it based on the default language setting of your document.

Theoretically, you can change the setting by double clicking it in the status bar at the bottom but this option doesn't seem to work for me in Word 2007 (I can set it to all I want, nothing changes). If it works for you, try that. Otherwise read further.

The default language setting is based on your keyboard setting (I have no clue as to why) which can be set in Windows in "Control Panel"->"Regional and Language Options"->"Keyboard and Languages"->"Change keyboards..."->"Default input language". If you set that to Portuguese, then the value behind "\l" will be what you want.

Aug 1, 2009 at 10:13 AM

I had tried that before, but it didn't work in my case either. Once you insert the citation, the language is defined and doesn't change, even if you change it within Word.

 

But it does work the other way you said, even easier: I got the keyboard-local switch in the taskbar, so now I just change from German to Portuguese by clicking Alt-Shift BEFORE I insert a citation, and click Alt-Shift again afterward. So my keyboard stays German, but the citation is registered as Portuguese.

 

Problem solved, thanks a lot Yves!

Aug 10, 2009 at 3:42 PM

I wonder if I couldn't change the language globally in the style template, that would be the easiest solution. Then I would just make various copies of the styles I use, e.g. "APA PT" and "APA GE" for Portuguese and German citation style.

Coordinator
Aug 10, 2009 at 7:25 PM

You could do that.

To change the name of a predefined style see http://bibword.codeplex.com/Wiki/View.aspx?title=FAQ#Q8

I don't have time to test this, but it looks like the LCID variable is declared at the beginning of a citation and a bibliography:

<xsl:variable name="LCID">
  <xsl:choose>
    <xsl:when test="b:LCID='0' or b:LCID='' or not(b:LCID)">
      <xsl:value-of select="/*/b:Locals/b:DefaultLCID"/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:value-of select="b:LCID"/>
    </xsl:otherwise>
  </xsl:choose>
</xsl:variable>

So changing that this to your required value (2070 for Portuguese) might do the trick:

<xsl:variable name="LCID">
  <xsl:text>2070</xsl:text>
</xsl:variable>
There is also a template called "localLCID". I'm guessing something similar should be done there, so it looks like: 

 <xsl:template name="localLCID">
  <xsl:param name="LCID"/>

  <xsl:text>2070</xsl:text>
</xsl:template>

Keep in mind that I haven't tested any of this code.

Aug 11, 2009 at 8:17 AM

Unfortunately it didn't work out. The first solution didn't change anything, the second omitted the page number indicator altogether...

Coordinator
Aug 11, 2009 at 7:07 PM

I just ran tested some things and found out that what you want is not directly possible.

The b:Locals element send with a bibliography or citation is not a full tree. That is, only for a limited set of LCIDs, the localized data strings are provided. Hence, changing the LCID inside the XSL is of no use as the b:Locals tree will/might not contain the required information for the changed LCID. Moreover, because there is no information at all, the elements (such as the page number indicator) will be gone completely as there is no fallback to the default language.

One solution could be do create a style which does nothing more than dumping a b:Locals tree. Then in your style, you could hardcode that tree and overwrite the custom tree that was attached by Word to your sources. Doable but a lot of work.

Alternatively, you could run a macro in Word which just updates all citation and bibliography fields to use your lcid. A crude attempt at such a macro is:

Sub SetFieldsLanguage()
    Dim showcodes As Boolean
    Dim fld As Field
    Dim lcid As String
            
    On Error GoTo cleanup
            
    lcid = InputBox("Please enter the 4-digit LCID for the citations and bibliography (e.g. 1033):", "LCID")
      
    ' Turn of screen updates.
    Application.ScreenUpdating = False
    
    ' Switch to design mode. (This is necessary because CITATION fields are locked otherwise)
    'ActiveDocument.ToggleFormsDesign

    ' Store the value indicating if fields are shown or not.
    showcodes = ActiveWindow.View.ShowFieldCodes
    
    ' Switch to field code view.
    If ActiveWindow.View.ShowFieldCodes = False Then
        ActiveWindow.View.ShowFieldCodes = True
    End If

    ' Go over all stories, including main, footnotes, ...
    For Each sr In ActiveDocument.StoryRanges
        ' Find all citation fields and convert them to static text.
        For Each fld In sr.Fields
            If fld.Type = wdFieldCitation Or fld.Type = wdFieldBibliography Then
                ' Select the code.
                fld.Code.Select
                
                ' Find the \l parameter followed by 4 digits
                Selection.Find.ClearFormatting
                Selection.Find.Replacement.ClearFormatting
                With Selection.Find
                   .Text = "(\\l*)[0-9][0-9][0-9][0-9]"
                   .Replacement.Text = "\1" + lcid
                   .Forward = True
                   .Wrap = wdFindContinue
                   .Format = False
                   .MatchWildcards = True
                End With
                ' Replace the lcid by the given value.
                Selection.Find.Execute Replace:=wdReplaceAll
            End If
        Next
    Next

    ' Switch back from field code view.
    If ActiveWindow.View.ShowFieldCodes = Not showcodes Then
        ActiveWindow.View.ShowFieldCodes = showcodes
    End If

    ' Switch back to normal mode.
    'ActiveDocument.ToggleFormsDesign
    
cleanup:
    Application.ScreenUpdating = True

End Sub

Note that for the macro to work correctly, you have to be in Design Mode when you run it. This is because citation fields are locked for manual editing. The Design mode button can be found on the Developer tab. Also, like I stated above, I have not tested this macro extensively, so it might not always work.

Aug 11, 2009 at 8:22 PM

I'll try that, thank a lot...

Oct 8, 2010 at 6:07 PM

hello everyone,

 

i really hope you can help even though posts here are from last year and i even think you already gave the solution to my problem but i just didn´t understand.

i have a german version of word 2007 and even when i change the language in word options references are still in german e.g. German: Name1 und Name2 or instead of "p." for page it says "S."

 

but i need English: Name1, and Name2 or "p." for page

is there any easy way to solve my problem? i really don´t know much about programming so, please explain as much as possible!!!

 

thanks a lot!!

Coordinator
Oct 8, 2010 at 8:03 PM

If you are talking about one of the styles you got from this site, then there is no German version. All styles are English only and will remain that way. The only way to get them into another language is by translating them yourselves.

If you are talking about the styles that come with Word 2007/2010, then you should try to manually change the value of the \l flag to fit your needs. Put your mouse on the bibliography, right click and select "Edit Field...". A window will popup and in it, you will see something like "BIBLIOGRAPHY \l 2070". The value after the "\l" decides on the language of the bibliography. A full list of LCID values can be found at http://msdn.microsoft.com/en-us/goglobal/bb964664.aspx. You should use the decimal numbers (LCID Dec column). Change that value to the one in which language you want your bibliography displayed. Afterwards, right click again on your bibliography and select "Update Field" to see the change in language.

Note that the value behind the "\l" parameter is only used for sources with their language set to "Default" (LCID = 0). If you set your source to a specific language, then that language will be used to format that one source in your bibliography.

Aug 27, 2013 at 11:52 AM
Edited Aug 27, 2013 at 11:59 AM
Hello
I have the same problem,
my article has multiple language references(English reference and Persian reference) .I want Localization my bibliography styles as Microsoft word default bibliography styles do.
I change IEEE_Alphabetical.XSL for Persian and it's ok ,but for English reference it not good.

what is the best way to do it?
is it possible to use 2 style for 2 language in word 2013?