Currently I'm building a tool to add/update translation data and generate an XML file for the program that is using that data.
I read in the XMLfile and store it in a database so that we can also use the data later to create other translation files.
To get the data from the database into the tool I generate a SQL query based on the amound of possible translations (stored in a different table) an join them with the translation data based on an ID. Inside the tool I'm using a dataTable and for this I'm trying to dynamicly swap rowdata to an column. This should be easy but I'm struggeling with it.
There are two tables, one with the locales and one with the data.
[dbo].[Locales]
[Id] [int] IDENTITY(1,1) NOT NULL
[Locale] [nvarchar](10) NOT NULL
[dbo].[Translations]
[Id] [int] IDENTITY(1,1) NOT NULL
[TranslationID] [int] NOT NULL
[Text] [nvarchar](max) NULL
[LocaleID] [int] NOT NULL
The translation data is look like:
TranslationID | Text | Locale |
---|---|---|
1 | Conexiones | es_ES |
1 | Anschlüsse | de_DE |
1 | Connection points | en_US |
1 | Aansluitingen | nl_NL |
2 | Spannungsversorgung | de_DE |
2 | Power supply | en_US |
How I want it:
TranslationID | nl_NL | en_US | de_DE | es_ES | x_X |
---|---|---|---|---|---|
1 | Aansluitingen | Connection points | Anschlüsse | Conexiones | null |
2 | Voeding | Power suply | Spannungsversorgung | null | some language |
I have tried to get the data with use of LEFT JOIN and OUTER JOIN without succes. The problem is that there is not for every translation data availible (thats the reason for building a tool for it). I also have found "PIVOT" but it looks like it can not generate the data as I want it because PIVOT wants an aggregation function.
Thanks in advance!