In order to import works in languages other than English, the API needs to accept a language_code string and then convert it to the language_id supported by the Archive. The string will need to match the ISO short name for the language (eg: "en" for locale-neutral English, "es" for Spanish etc) as this can then be matched to the "short" column in the Archive database.
The StoryParser already supports adding the "language_id" to a work, so it's just a matter of handling this properly in the API. AO3-4605 covers wiring the language option into the UI.
Testing Notes
This is covered by an automated test but can be tested manually from RubyMine by pasting this code block (see instructions here), or this can be adapted to a REST client of your choice (token for Test will be provided on request and remember to set the archivist to an account with archivist permissions on Test):
The resulting work should then have its language set to Spanish.
Indirect Testing
To ease testing, I’ve set half the works on this page to Spanish, and half to German, so importing them should create a work with one or the other: http://od-import.transformativeworks.org/test/authors?letter=M - to import using the API, click on the Import All button beside the author’s name.
http://od-import.transformativeworks.org/test/authors?letter=M
"Import All" on "M Author", resulting work has language set to German: https://test.archiveofourown.org/works/1069441
"Import All" on "M Author 2", resulting work has language set to Spanish: https://test.archiveofourown.org/works/1069444
Looks good.
I did “Import All” on “M Author 11” and https://test.archiveofourown.org/works/1069447 had its language set to German.
Looks good!
Looks good!