[Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?

8 views
Skip to first unread message

Ron Van den Branden

unread,
Dec 6, 2023, 9:51:14 AM12/6/23
to archivesspac...@lyralists.lyrasis.org
Hi all,
We're in the process of customizing the ArchivesSpace (3.4.1) staff interface for use in a Dutch-speaking context. We would like to translate the back-end user interface to Dutch. So far, in order to gain speed, we've resorted to tweaking the en.yml localization files with Dutch labels. In the longer run, hijacking "English" for another language feels like a hack, though.
The documentation for "customizing text" at https://archivesspace.github.io/tech-docs/customization/locales.html  does mention where strings can be customized in current locales, but not how new locales can be added. Simply adding new locale files for new languages, with according names and language codes, at the right locations doesn't seem to do the trick:
  • either the language is not being offered in the list of available languages
  • when additionally the new language is specified explicitly in the config/config.rb file as AppConfig[:locale] = :nl , this yields following error at startup:
    JSONModel::ValidationException: #<:ValidationException: {:errors=>{"defaults/locale"=>["Invalid value 'nl'.  Must be one of: en, fr, de, ja, es"]}}>
                          validate at uri:classloader:/jsonmodel_type.rb:385
                with_validator_for at uri:classloader:/validator_cache.rb:41
...so there must be more to adding a new locale. Yet, we can't find where in the ArchivesSpace distribution code such a list of default locales can be found or edited.
We did find the file in the ArchivesSpace source tree at https://github.com/archivesspace/archivesspace/blob/master/common/aspace_i18n.rb#L28 which defines above list of locales This file can't be found in the distribution code, however, so it's not clear how it relates to the distribution code. The commit history also shows commits from the Weblate project at https://hosted.weblate.org/projects/archivesspace-interfaces/#languages, which contains additional languages Portuguese and Italian.
This leads to following questions:
  • what's the mechanism for adding a new locale to an ArchivesSpace instance?
  • if our translations would reach a stage of being of broader interest, what would be the procedure for contributing them?
Kind regards,
Ron

Ron Van den Branden | functioneel analist - applicatiebeheerder Letterenhuis

Stad Antwerpen | Talentontwikkeling en Vrijetijdsbeleving |  Boeken en Letteren

Minderbroedersstraat 22, 2000 Antwerpen

Grote Markt 1, 2000 Antwerpen

gsm +32 0485 02 80 50 | tel. +32 3 222 93 30

letterenhuis.be | instagram | facebook

 

Proclaimer

Vergissen is menselijk. Dus als deze e-mail, samen met eventuele bijlagen, niet voor u bestemd is, vragen we u vriendelijk om dat te melden aan de afzender. Deze e-mail en de bijlagen zijn namelijk officiële documenten van de stad Antwerpen. Ze kunnen vertrouwelijke of persoonlijke informatie bevatten. Als stad nemen we privacy heel serieus en willen we als een goede huisvader waken over de vertrouwelijkheid van documenten. Als u dit bericht per vergissing hebt ontvangen of ergens hebt gevonden, wees dan zo eerlijk om het meteen te verwijderen en het niet verder te verspreiden of te kopiëren.


Christine Di Bella

unread,
Dec 6, 2023, 10:42:05 AM12/6/23
to Archivesspace Users Group

Hello Ron,

 

It’s great to hear that you’re working on customizing your interfaces to have the option of providing labels in Dutch. I believe there are some institutions in the Netherlands, Belgium, and Luxembourg that have already done that, and you may hear from them here or directly. That would likely give you a very significant head start on your customization.

 

The Dutch translations themselves have not been contributed to the core ArchivesSpace yet, but we would be very interested in having them. We have a few options for contributing translations to ArchivesSpace, including using the Weblate service. If you are comfortable working directly with the .yml files, however, you need to first grab the ones from our GitHub repository itself. If you only use the ones in a release distribution file, your interface will be only partially translated.

 

These are the six directories to look for:

https://github.com/archivesspace/archivesspace/tree/master/common/locales

https://github.com/archivesspace/archivesspace/tree/master/common/locales/enums

https://github.com/archivesspace/archivesspace/tree/master/frontend/config/locales

https://github.com/archivesspace/archivesspace/tree/master/frontend/config/locales/help

https://github.com/archivesspace/archivesspace/tree/master/public/config/locales

 

https://github.com/archivesspace/archivesspace/tree/master/reports (there are locale files for each of the reports in the subdirectories under this main directory)

 

It’s probably easiest to use the en.yml ones as your starting point since the labels in the file (the text that appears before the colons) need to stay in English. Follow the pattern you see and make a set where each file is named nl.yml. Within the files, change the text that appears after the colon for each entry you want to be in Dutch. (Don’t change any of the formatting or line spacing since a computer is very literal.)

 

Once you’ve made all the changes you want, you can pull request the new files to us via GitHub, we can review, and then when all is correct and working like it should we will include them in a future release of ArchivesSpace.

 

There’s plenty more to say, but I’ll start there and see if anyone who’s currently working with a translated interface or with translations has advice to offer. We’re always interested in people submitting more languages for the ArchivesSpace application or improving the ones we have.

 

Christine

 

Christine Di Bella

ArchivesSpace Senior Program Manager

christin...@lyrasis.org

 

Joshua D. Shaw

unread,
Dec 6, 2023, 10:44:20 AM12/6/23
to Archivesspace Users Group
Hey Ron

In addition to what Christine lists....

Off the top of my head (so take with a grain of salt since I haven't actually tested this!)...

In a plugin init (probably a backend plugin_init), monkey patch the self.supported_locales method in common/aspace_i18n.rb. Maybe something like

module I18n
def self.supported_locales
      enhanced_locales = LOCALES

      # map I18n language code => ArchivesSpace enumerations:language_iso639_2 code
      # enumerations iso codes found in common/locales/enums
      enhanced_locales['nl'] = 'dut'

      enhanced_locales
end
end

Then you could add your new dutch locale file nl.yml within that same plugin.

OR

You could grab the code tree from github, patch it locally and build your patched application.

Both approaches have their own set of headaches as far as maintenance.


Hope that helps!
Joshua





Sent: Wednesday, December 6, 2023 9:51 AM

Subject: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?

Ron Van den Branden

unread,
Dec 6, 2023, 10:57:06 AM12/6/23
to Archivesspace Users Group
Hi Christine,

Many thanks for your detailed answer, and the complete overview of where to look for localization files.

Editing the yml files (at least those under common and frontend) is exactly the approach we've taken. So far, with the "hack" of editing the translations in the en.yml files.

I appreciate including a new translation into the ArchivesSpace code would take some time and thourough review. What I'm missing, still, is an answer to the question whether it's possible in the meantime to "properly" add a new localization, and register those nl.yml files as a NL localization in an ArchivesSpace distribution. That would make it easier, IMO, to share and contribute those Dutch translation files in an earlier stage with potential interested parties, and offer them in a more mature stage for inclusion into ArchivesSpace.

Best,

Ron


Van: archivesspace_us...@lyralists.lyrasis.org <archivesspace_us...@lyralists.lyrasis.org> namens Christine Di Bella <christin...@lyrasis.org>
Verzonden: woensdag 6 december 2023 16:42
Aan: Archivesspace Users Group <archivesspac...@lyralists.lyrasis.org>
Onderwerp: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
 

WAARSCHUWING: DIT IS EEN EXTERNE MAIL

Deze mail komt van buiten onze organisatie. Kijk eerst of je het mailadres en de afzender herkent en/of vertrouwt. Doe dat voor je bijlagen opent of links aanklikt. Zo houden we onze organisatie veiliger voor phishing. 

Ron Van den Branden

unread,
Dec 6, 2023, 11:01:51 AM12/6/23
to Archivesspace Users Group
Hi Joshua,

Ok, thanks for that pointer! The point is that we couldn't find that common/aspace_i18n.rb file in the ArchivesSpace distribution code. Or are you suggesting to add it in a plugin? If so, would you mind guiding me a bit more?

I don't think we've succeeded in building from source (I'm on Windows, so I'm probably at a loss for local testing, I recall some Ruby build incompatibilities). 

Best,

Ron


Van: archivesspace_us...@lyralists.lyrasis.org <archivesspace_us...@lyralists.lyrasis.org> namens Joshua D. Shaw <Joshua...@dartmouth.edu>
Verzonden: woensdag 6 december 2023 16:44

Aan: Archivesspace Users Group <archivesspac...@lyralists.lyrasis.org>
Onderwerp: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
 

WAARSCHUWING: DIT IS EEN EXTERNE MAIL

Deze mail komt van buiten onze organisatie. Kijk eerst of je het mailadres en de afzender herkent en/of vertrouwt. Doe dat voor je bijlagen opent of links aanklikt. Zo houden we onze organisatie veiliger voor phishing. 

Hey Ron

Joshua D. Shaw

unread,
Dec 6, 2023, 11:21:43 AM12/6/23
to Archivesspace Users Group
Hey Ron

Here's the way I'd do this.

  1. Create a new directory in the plugin folder in your ArchivesSpace directory. Call it something like aspace_custom_locatizations (or whatever you want)
  2. In that new directory, create two new directories: backend and frontend
  3. In the backend directory, add a file called plugin_init.rb. Put the contents of the monkey patch in that file
  4. In the frontend directory, add a file tree that mimics the locales directory in the core code:
    1. locales/
    2. locales/enums
  5. Add your new dutch locales files to those two locations. Name them nl.yml
  6. In your config file, add your plugin name (the directory name in step 1) to the list of plugins that are active: AppConfig[:plugins] is the key you want to edit.

Since I haven't tested this, there may be some gotchas I'm not thinking about as far as the monkeypatch and where the locales list may also be referenced, but this is the approach I'd take.

There's more info on that tech docs page and there are a bunch of examples to be found on the Awesome ArchivesSpace repo (https://github.com/archivesspace/awesome-archivesspace) and Hudson Molonglo's repos (https://github.com/hudmol) and https://gitlab.gaiaresources.com.au/explor

jds



Sent: Wednesday, December 6, 2023 11:01 AM
To: Archivesspace Users Group <archivesspac...@lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
 

Ron Van den Branden

unread,
Dec 6, 2023, 12:00:14 PM12/6/23
to Archivesspace Users Group
Hi Joshua,

Thanks again for your detailed steps! Although a first attempt didn't work (startup keeps choking on the original languages list), I'm sure we'll get there, with more time. Thanks for pointing me in the good direction: overriding the language list via plugin initialization. I'll definitely check out those other plugins for inspiration.

Best,

Ron



Verzonden: woensdag 6 december 2023 17:21

Joshua D. Shaw

unread,
Dec 6, 2023, 1:13:31 PM12/6/23
to Archivesspace Users Group
One thing you might try is initializing the AppConfig[:locale] setting  in the plugin itself, since it may be an order of operations issue where the main config loads first which attempts to initialize an unknown language (because the plugin hasn't loaded yet).

jds



Sent: Wednesday, December 6, 2023 12:00 PM

Joshua D. Shaw

unread,
Dec 6, 2023, 4:03:41 PM12/6/23
to Archivesspace Users Group
The other way to do this (a bit hacky) is to expand the common.jar file in /lib, make your edits to the relevant I18n file (common/aspace_i18n.rb), and then recompress the jar file.

This works for any edits you need to core, but its hacky because its not really a sustainable way to do things since you need to edit the same file for every​ update to the core code.

jds



From: archivesspace_us...@lyralists.lyrasis.org <archivesspace_us...@lyralists.lyrasis.org> on behalf of Joshua D. Shaw <Joshua...@dartmouth.edu>
Sent: Wednesday, December 6, 2023 1:13 PM

Christine Di Bella

unread,
Dec 6, 2023, 7:39:46 PM12/6/23
to Archivesspace Users Group

Hi Ron,

 

It sounds like Joshua has given you good guidance for making translations work in your local deployment in the interim, but if you get to the point where you’re ready to share the in-progress translation with an eye toward it going into the core code eventually, please let me know. There’s the pull request option I mentioned before, but we also use a service called Weblate where translations can be worked on in a crowdsourced way. We’d love to get a Dutch set started on it.

 

Christine

 

Sent: Wednesday, December 6, 2023 10:57 AM
To: Archivesspace Users Group <archivesspac...@lyralists.lyrasis.org>

Joshua D. Shaw

unread,
Dec 7, 2023, 8:29:54 AM12/7/23
to Archivesspace Users Group
Because I was curious, I tested this out and created a small plugin that supports this feature: https://github.com/dartmouth-dltg/aspace_custom_localizations

I tested this against 3.4.1, but I believe it will work with most any version of ArchivesSpace.

Hopefully the ReadMe is self explanatory, but let me know if things are unclear.

jds

Sent: Wednesday, December 6, 2023 4:03 PM

Joshua D. Shaw

unread,
Dec 7, 2023, 1:27:24 PM12/7/23
to Archivesspace Users Group
I'm working with Ron to resolve a couple of issues with the plugin and will report back when those are sorted.

jds


Sent: Thursday, December 7, 2023 8:29 AM

Ron Van den Branden

unread,
Dec 14, 2023, 4:24:23 AM12/14/23
to Archivesspace Users Group
Without wanting to steal Joshua's thunder, the plugin he promptly created is working fine in its current state:
  • allowing one to specify a custom locale
  • providing a fallback to a default locale for labels missing in that custom locale
It's dead easy to install, and all nicely documented at https://github.com/dartmouth-dltg/aspace_custom_localizations/, I can't thank you enough, Joshua!

We'll start using this in our system, with Dutch translations for the back-end, front-end, and report sections. The public translation file doesn't look too big, so it should be within reach to translate that as well. 

I'm glad the plugin provides a stable way to deploy these custom locales without hacks. This makes it much easier to share them with other parties interested in preparing a complete Dutch translation for future contribution to the ASpace code base. To anyone interested in the Dutch user community: please get in touch!

Best,

Ron


Verzonden: donderdag 7 december 2023 19:27

Joshua D. Shaw

unread,
Dec 14, 2023, 6:57:13 AM12/14/23
to Archivesspace Users Group
Just wanted to chime in to say this was an interesting challenge involving some pieces of ArchivesSpace that I hadn't poked around in as much. Having someone to test the changes was super helpful, so thanks to Ron for that side of things! 

I'd also like to emphasize that the main goal for anyone using the plugin will hopefully be eventual contribution of their custom localizations to core. The more languages represented in core, the better!

Please send any bug reports or thoughts for enhancements my way.

Joshua



Sent: Thursday, December 14, 2023 4:24 AM
Reply all
Reply to author
Forward
0 new messages