[Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
Ron Van den Branden
Ron.VandenBranden at antwerpen.be
Thu Dec 14 04:24:23 EST 2023
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
________________________________
Van: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> namens Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Verzonden: donderdag 7 december 2023 19:27
Aan: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Onderwerp: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
U ontvangt niet vaak e-mail van joshua.d.shaw at dartmouth.edu. Meer informatie over waarom dit belangrijk is<https://aka.ms/LearnAboutSenderIdentification>
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.
I'm working with Ron to resolve a couple of issues with the plugin and will report back when those are sorted.
jds
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Sent: Thursday, December 7, 2023 8:29 AM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Sent: Wednesday, December 6, 2023 4:03 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Sent: Wednesday, December 6, 2023 1:13 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Ron Van den Branden <Ron.VandenBranden at antwerpen.be>
Sent: Wednesday, December 6, 2023 12:00 PM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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
________________________________
Van: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> namens Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Verzonden: woensdag 6 december 2023 17:21
Aan: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Onderwerp: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
U ontvangt niet vaak e-mail van joshua.d.shaw at dartmouth.edu. Meer informatie over waarom dit belangrijk is<https://aka.ms/LearnAboutSenderIdentification>
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
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:
* locales/
* 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<https://gitlab.gaiaresources.com.au/explore>
jds
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Ron Van den Branden <Ron.VandenBranden at antwerpen.be>
Sent: Wednesday, December 6, 2023 11:01 AM
To: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Subject: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> namens Joshua D. Shaw <Joshua.D.Shaw at dartmouth.edu>
Verzonden: woensdag 6 december 2023 16:44
Aan: Archivesspace Users Group <archivesspace_users_group at lyralists.lyrasis.org>
Onderwerp: Re: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
U ontvangt niet vaak e-mail van joshua.d.shaw at dartmouth.edu. Meer informatie over waarom dit belangrijk is<https://aka.ms/LearnAboutSenderIdentification>
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
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.
To contribute and other tech docs: https://archivesspace.github.io/tech-docs/readme_develop.html
Hope that helps!
Joshua
________________________________
From: archivesspace_users_group-bounces at lyralists.lyrasis.org <archivesspace_users_group-bounces at lyralists.lyrasis.org> on behalf of Ron Van den Branden <Ron.VandenBranden at antwerpen.be>
Sent: Wednesday, December 6, 2023 9:51 AM
To: archivesspace_users_group at lyralists.lyrasis.org <archivesspace_users_group at lyralists.lyrasis.org>
Subject: [Archivesspace_Users_Group] how to add a new locale to ArchivesSpace?
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<http://www.letterenhuis.be/> | instagram<https://www.instagram.com/letterenhuis/> | facebook<https://www.facebook.com/Letterenhuis>
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lyralists.lyrasis.org/pipermail/archivesspace_users_group/attachments/20231214/c485fbd8/attachment.html>
More information about the Archivesspace_Users_Group
mailing list