Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We added "Attach file from URL" to right-click context menu to download and store a file with the reference library. [#9646](https://github.com/JabRef/jabref/issues/9646)
- We enabled updating an existing entry with data from InspireHEP. [#9351](https://github.com/JabRef/jabref/issues/9351)
- We added a fetcher for the Bibliotheksverbund Bayern (experimental). [#9641](https://github.com/JabRef/jabref/pull/9641)
- We added support for multiple languages for exporting to and importing references from MS Office. [#9699](https://github.com/JabRef/jabref/issues/9699)
- We enabled scrolling in the groups list when dragging a group on another group. [#2869](https://github.com/JabRef/jabref/pull/2869)




### Changed

- 'Get full text' now also checks the file url. [#568](https://github.com/koppor/jabref/issues/568)
Expand Down Expand Up @@ -381,7 +381,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve
- We moved the union/intersection view button in the group sidepane to the left of the other controls. [#8202](https://github.com/JabRef/jabref/pull/8202)
- We improved the Drag and Drop behavior in the "Customize Entry Types" Dialog [#6338](https://github.com/JabRef/jabref/issues/6338)
- When determining the URL of an ArXiV eprint, the URL now points to the version [#8149](https://github.com/JabRef/jabref/pull/8149)
- We Included all standard fields with citation key when exporting to Old OpenOffice/LibreOffice Calc Format [#8176](https://github.com/JabRef/jabref/pull/8176)
- We Included all standard fields with citation key when exporting to Old OpenOffice/LibreExpoa Calc Format [#8176](https://github.com/JabRef/jabref/pull/8176)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Siedlerchr What is "LibreExpoa"? Is this change in CHANGELOG.md really intended?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was editing this on the github, this was not intended

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed it directly in main at 461e915

- In case the database is encoded with `UTF8`, the `% Encoding` marker is not written anymore
- The written `.bib` file has the same line endings [#390](https://github.com/koppor/jabref/issues/390)
- The written `.bib` file always has a final line break
Expand Down
1 change: 0 additions & 1 deletion src/main/java/org/jabref/logic/msbib/MSBibConverter.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ public static MSBibEntry convert(BibEntry entry) {
result.journalName = entry.getFieldOrAliasLatexFree(StandardField.JOURNAL).orElse(null);

// Value must be converted
// Currently only english is supported
entry.getLatexFreeField(StandardField.LANGUAGE)
.ifPresent(lang -> result.fields.put("LCID", String.valueOf(MSBibMapping.getLCID(lang))));
StringBuilder sbNumber = new StringBuilder();
Expand Down
58 changes: 48 additions & 10 deletions src/main/java/org/jabref/logic/msbib/MSBibMapping.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jabref.model.entry.types.IEEETranEntryType;
import org.jabref.model.entry.types.StandardEntryType;

import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;

/**
Expand All @@ -22,7 +23,48 @@ public class MSBibMapping {
private static final String BIBTEX_PREFIX = "BIBTEX_";
private static final String MSBIB_PREFIX = "msbib-";

private static final HashBiMap<Field, String> BIBLATEX_TO_MS_BIB = HashBiMap.create();
private static final BiMap<Field, String> BIBLATEX_TO_MS_BIB = HashBiMap.create();


// https://learn.microsoft.com/en-us/openspecs/office_standards/ms-oe376/6c085406-a698-4e12-9d4d-c3b0ee3dbc4a
private static final BiMap<String, Integer> LANG_TO_LCID = HashBiMap.create();

static {
LANG_TO_LCID.put("basque", 1609);
LANG_TO_LCID.put("bulgarian", 1026);
LANG_TO_LCID.put("catalan", 1027);
LANG_TO_LCID.put("croatian", 1050);
LANG_TO_LCID.put("czech", 1029);
LANG_TO_LCID.put("danish", 1030);
LANG_TO_LCID.put("dutch", 1043);
LANG_TO_LCID.put("english", 1033); // american english
LANG_TO_LCID.put("finnish", 1035);
LANG_TO_LCID.put("french", 1036);
LANG_TO_LCID.put("german", 1031);
LANG_TO_LCID.put("austrian", 3079);
LANG_TO_LCID.put("swissgerman", 2055);
LANG_TO_LCID.put("greek", 1032);
LANG_TO_LCID.put("hungarian", 1038);
LANG_TO_LCID.put("icelandic", 1039);
LANG_TO_LCID.put("italian", 1040);
LANG_TO_LCID.put("latvian", 1062);
LANG_TO_LCID.put("lithuanian", 1063);
LANG_TO_LCID.put("marathi", 1102);
LANG_TO_LCID.put("nynorsk", 2068);
LANG_TO_LCID.put("polish", 1045);
LANG_TO_LCID.put("brazil", 1046);
LANG_TO_LCID.put("portuguese", 2070);
LANG_TO_LCID.put("romanian", 1048);
LANG_TO_LCID.put("russian", 1049);
LANG_TO_LCID.put("serbian", 2074);
LANG_TO_LCID.put("serbianc", 3098);
LANG_TO_LCID.put("slovak", 1051);
LANG_TO_LCID.put("slovene", 1060);
LANG_TO_LCID.put("spanish", 3082);
LANG_TO_LCID.put("swedish", 1053);
LANG_TO_LCID.put("turkish", 1055);
LANG_TO_LCID.put("ukrainian", 1058);
}

static {
BIBLATEX_TO_MS_BIB.put(InternalField.KEY_FIELD, "Tag");
Expand Down Expand Up @@ -123,27 +165,23 @@ public static MSBibEntryType getMSBibEntryType(EntryType bibtexType) {
}

/**
* Only English is supported <br>
* <a href="http://www.microsoft.com/globaldev/reference/lcid-all.mspx">All LCID codes</a>
*
* @param language The language to transform
* @return Returns 0 for English
* @return 1033 (american english) as default. LCID otherwise.
*/
public static int getLCID(String language) {
// TODO: add language to LCID mapping
// 0x0409 is American English
return 0x0409;
return LANG_TO_LCID.getOrDefault(language, 1033);
}

/**
* Only English is supported <br>
* <a href="http://www.microsoft.com/globaldev/reference/lcid-all.mspx">All LCID codes</a>
*
* @return Returns english
* @param LCID The LCID to transform
* @return "english" as default. Corresponding language from BiMap otherwise.
*/
public static String getLanguage(int LCID) {
// TODO: add language to LCID mapping
return "english";
return LANG_TO_LCID.inverse().getOrDefault(LCID, "english");
}

public static String getMSBibField(Field field) {
Expand Down
42 changes: 42 additions & 0 deletions src/test/java/org/jabref/logic/msbib/MSBibConverterTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.jabref.logic.msbib;

import java.util.Optional;

import org.jabref.model.entry.BibEntry;
import org.jabref.model.entry.field.StandardField;
import org.jabref.model.entry.types.StandardEntryType;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

class MSBibConverterTest {

private final BibEntry BIB_ENTRY_TEST = new BibEntry(StandardEntryType.InProceedings)
.withField(StandardField.AUTHOR, "Igor Steinmacher and Tayana Uchoa Conte and Christoph Treude and Marco Aurélio Gerosa")
.withField(StandardField.DATE, "14-22 May 2016")
.withField(StandardField.YEAR, "2016")
.withField(StandardField.EVENTDATE, "14-22 May 2016")
.withField(StandardField.EVENTTITLEADDON, "Austin, TX, USA")
.withField(StandardField.LOCATION, "Austin, TX, USA")
.withField(StandardField.DOI, "10.1145/2884781.2884806")
.withField(StandardField.JOURNALTITLE, "2016 IEEE/ACM 38th International Conference on Software Engineering (ICSE)")
.withField(StandardField.PAGES, "273--284")
.withField(StandardField.ISBN, "978-1-5090-2071-3")
.withField(StandardField.ISSN, "1558-1225")
.withField(StandardField.LANGUAGE, "english")
.withField(StandardField.PUBLISHER, "IEEE")
.withField(StandardField.KEYWORDS, "Portals, Documentation, Computer bugs, Joining processes, Industries, Open source software, Newcomers, Newbies, Novices, Beginners, Open Source Software, Barriers, Obstacles, Onboarding, Joining Process")
.withField(StandardField.TITLE, "Overcoming Open Source Project Entry Barriers with a Portal for Newcomers")
.withField(StandardField.FILE, ":https\\://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=7886910:PDF");

private BibEntry entry;

@Test
void convert() {
entry = BIB_ENTRY_TEST;
MSBibConverter.convert(entry);

assertEquals(Optional.of("english"), entry.getField(StandardField.LANGUAGE));
}
}
31 changes: 31 additions & 0 deletions src/test/java/org/jabref/logic/msbib/MsBibMappingTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jabref.logic.msbib;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertEquals;

public class MsBibMappingTest {
@Test
public void testGetLanguage() {
String lang = MSBibMapping.getLanguage(1609);
assertEquals("basque", lang);
}

@Test
public void testGetLCID() {
int lcid = MSBibMapping.getLCID("basque");
assertEquals(1609, lcid);
}

@Test
public void testGetInvalidLanguage() {
String lang = MSBibMapping.getLanguage(1234567);
assertEquals("english", lang);
}

@Test
public void testInvalidLCID() {
int lcid = MSBibMapping.getLCID("not a language");
assertEquals(1033, lcid);
}
}