The Localazy SQL-driver enables both read and write operations on Localazy using a virtual Invantive UniversalSQL-database. The driver is optimized for high volumes of translation keys.
The following code downloads all translations from a Localazy project configured on the data container alias lzy
and where missing adds them to the Invantive Producer translation repository stored in the Oracle-table itgen_translations_v
:
create or replace table translations@inmemorystorage
as
select 'repos/itgen/trunk' apn_code
, keys tln_resource_code
, value tln_text
, language_code lge_code
from Localazy.Views.ProjectFileKeys@lzy t
declare
g_source_language varchar2 := 'en';
begin
for r
in
( select apn_code
, lge_code
, tln_resource_code
, tln_text
from translations@inmemorystorage
where language_code != g_source_language
minus
select apn_code
, lge_code
, tln_resource_code
, tln_text
from itgen_translations_v@ora
where apn_code = 'repos/itgen/trunk'
and lge_code != g_source_language
order
by tln_resource_code
)
loop
begin
insert into itgen_translations_v@ora
( apn_code
, lge_code
, tln_resource_code
, tln_text
)
values
( r.apn_code
, r.lge_code
, r.tln_resource_code
, r.tln_resource_text
);
dbms_output.put_line('Loaded ' || r.tln_resource_code);
exception
when others
then
dbms_output.put_line('Failed on ' || r.tln_resource_code|| ': ' || sqlerrm);
end;
end loop;
end;
A more efficient way in terms of operations and inclusion of resourec key translation updates too, is to replace the code block starting at declare
by the following statement as described in Synchronize your Data with one Statement across multiple Applications using the most simple synchronize
statement:
synchronize translations@inmemorystorage
to itgen_translations_v
with insert or update
identified
by apn_code
, lge_code
, tln_resource_code
The synchronize statement only issues updates and deletes when it finds the either the translation row is missing in the target table or when the translation has been altered.
Vice versa, to upload data into Localazy, a synchronize
statement can be used which exchanges source and table, using ProjectFileKeys
to download the current contents of the project in Localazy in a fast way for the source language, compares them in an efficient way with an in-memory table of `itgen_translations_v with renamed column names and solely the source language keys and translations, and then issues only the necessary changes to make Localazy more current.