altinn-studio icon indicating copy to clipboard operation
altinn-studio copied to clipboard

Handle syncing of text-files when adding new texts in backend

Open standeren opened this issue 1 year ago • 1 comments

Description

Today we have to ways to add a new text to the text-file(s).

  1. Either add it from the text-editor; then you will add a new text-id and an empty text to all text-files
  2. Or you can add it from the "lage" page; then you will add a new text-id with the text written in the text-box to only the chosen language.

This is not a problem alone, but with todays implementation of the text editor you might experience some weird behaviour. If you have multiple languages and do not add the text to all langauges from the "lage"-page it will only live in some of the text-files. When rendering the text-editor the textEditor component will start filling out the text rows from the language that is first in alphabetical order (I think) and if this file does not have the newly added text it will place its own texts first.

Proposed Solution

Instead of handling the syncing between the language files in frontend, which we now do when adding a text from the text-editor (we do one call for updating the text-file per language), we should only send the PUT call to a single language and the backend should check if the ID exists and add it to all files if it does not. We will only need to check the language file which the call was made to, since we can assume that this solution will always provide consistency between all files.

Breaking Change ⚠

Even though this solution will work for new apps, and apps that already have synced text files (meaning that all text-ids are present in all language files), it may introduce issues for apps that have added text to only some languages from the lage-page. If that is the case they will have text-ids that are not present in all files. If then adding a text to another language from lage-page after this change, they will experience that the languages that they already had added this text-key to, will get a new entry with the same text-key on the top of the file but with no text-content.

Additional Information

Today, when we do updates to the text-files by adding a single text-textkey-entry to a language we manipulate the cache directly and add this entry at the beginning of list for the specific language. We should maybe not do this as this will only modify the list for the given language in frontend, but in reality all lists are changed in backend. So frontend kust fetch new updated lists of all files.

standeren avatar Jan 17 '24 10:01 standeren

There is an issue when you have created a binding to the datamodel in the resource-file. When you add f.eks. "nynorsk" text, it doesn't save the nynorsk with the same "variables": values (unless it has been corrected now).

xmrsa avatar Apr 10 '24 09:04 xmrsa