Metadata Translator can now connect to online data models in SQL Server Analysis Services, Azure Analysis Services, and the Power BI service.

This commit is contained in:
Kay Unkroth 2021-03-02 17:09:30 -08:00
Родитель 9f886bdfaf
Коммит 6c7a6e1b1f
13 изменённых файлов: 496 добавлений и 356 удалений

Просмотреть файл

@ -7,6 +7,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Metadata Translator", "Meta
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Metadata Translator Setup", "Metadata Translator Setup\Metadata Translator Setup.vdproj", "{FC353DA7-B669-4EDF-B465-CB9827C7F035}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{13A368ED-B955-438D-9365-03E467A59DB0}"
ProjectSection(SolutionItems) = preProject
README.md = README.md
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using Microsoft.AnalysisServices;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
@ -13,7 +14,12 @@ namespace Metadata_Translator
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (System.Convert.ToBoolean(value))? Visibility.Collapsed : Visibility.Visible;
if(value is bool notVisible)
{
return notVisible ? Visibility.Collapsed : Visibility.Visible;
}
else
return (value == null)? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
@ -26,7 +32,12 @@ namespace Metadata_Translator
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (System.Convert.ToBoolean(value)) ? Visibility.Visible : Visibility.Collapsed;
if (value is bool notVisible)
{
return notVisible ? Visibility.Visible : Visibility.Collapsed;
}
else
return (value == null) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)

Просмотреть файл

@ -13,6 +13,9 @@ using System.Windows.Data;
using System.IO;
using System.Web.Script.Serialization;
using Microsoft.VisualBasic.FileIO;
using Adomd = Microsoft.AnalysisServices.AdomdClient;
using System.Text.RegularExpressions;
using System.Security.Cryptography;
namespace Metadata_Translator
{
@ -27,6 +30,9 @@ namespace Metadata_Translator
public string DefaultCulture { get; set; }
public string ServerName { get; private set; }
public string DatabaseName { get; private set; }
public List<string> CultureNames
{
get
@ -40,22 +46,72 @@ namespace Metadata_Translator
public List<Language> SelectedLanguages { get => SupportedLanguages?.Where(x => x.IsSelected==true).ToList(); }
public bool HasTargetLanguages { get => SelectedLanguages?.Count > 1; }
/// <summary>
/// Connect to the dataset by using server and database name. This is how external tools typically connect to a dataset inside of Power BI Desktop.
/// </summary>
/// <param name="server"></param>
/// <param name="database"></param>
public DataModel(string server, string database)
{
LoadLanguages();
ServerName = server;
DatabaseName = database;
Server pbiDesktop = new Server();
pbiDesktop.Connect($"Data Source={server}");
Database dataset = pbiDesktop.Databases.GetByName(database);
pbiDesktop.Connect($"Data Source={ServerName}");
Database dataset = pbiDesktop.Databases.GetByName(DatabaseName);
Model = dataset.Model;
DefaultCulture = Model.Culture;
Initialize();
}
/// <summary>
/// Connects to a dataset using a connection string. This is how tools typically connect to online datasets in SQL Server Analysis Services, Azure Analysis Services, and Power BI.
/// </summary>
/// <param name="connectionString"></param>
public DataModel(string connectionString)
{
/// Connect using the full connection string, as it may contain more than
/// just data source and intial catalog, such as user id and password.
///
Server pbiDesktop = new Server();
pbiDesktop.Connect(connectionString);
/// Parse the connection string using regex to avoid resolving server and database names through the AMO objects.
///
RegexOptions options = RegexOptions.IgnorePatternWhitespace | RegexOptions.Multiline | RegexOptions.IgnoreCase | RegexOptions.Compiled;
foreach (Match match in Regex.Matches(connectionString, "([^=;]*)=([^=;]*)", options))
{
string[] parts = match.Value.Split('=');
if (parts?.Length == 2 && parts[0].ToLower() == "data source")
{
ServerName = parts[1];
}
else if (parts?.Length == 2 && parts[0].ToLower() == "initial catalog")
{
DatabaseName = parts[1];
}
}
/// Select the database based on the extracted database name.
///
Database dataset = pbiDesktop.Databases.GetByName(DatabaseName);
Model = dataset.Model;
Initialize();
}
/// <summary>
/// Initializes the list of supported languages and the named object collections.
/// </summary>
private void Initialize()
{
LoadLanguages();
DefaultCulture = Model.Culture;
LoadNamedObjectCollections();
}
/// <summary>
/// A static helper to get the DataModel object.
/// A static helper to get the DataModel object based on server and database name.
/// </summary>
/// <param name="server"></param>
/// <param name="database"></param>
@ -65,6 +121,16 @@ namespace Metadata_Translator
return new DataModel(server, database);
}
/// <summary>
/// A static helper to get the DataModel object based on a connection string.
/// </summary>
/// <param name="connectionString"></param>
/// <returns></returns>
public static DataModel Connect(string connectionString)
{
return new DataModel(connectionString);
}
/// <summary>
/// Gets the tables from the dataset and within it all the columns, measures, and hierarchies
/// and adds these tabular objects to the collections for captions, descriptions, and display folders.

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Просмотреть файл

@ -88,10 +88,20 @@ Metadata Translator detects the default language and all translations in the dat
![Applying translations](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Applying%20translations.png)
## Connecting to an online dataset
Metadata Translator can also connect to data models hosted in SQL Server Analysis Services, Azure Analysis Services, and the Power BI service so you can add translations to an online dataset. Simply start Metadata Translator directly from the installation folder, type the full dataset connection string in the input form, and then click OK to connect.
![Connection string to a PowerBI dataset](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/ConnectionStringToAPowerBIDataset.png)
> Note
> You must provide the full connection string. This is especially important to keep in mind when connecting to a dataset in the Power BI service. The connection string that Power BI displays on the dataset settings page does not include the Data Source property name. It is an incomplete connection string, such as *powerbi://api.powerbi.com/v1.0/myorg/AdventureWorksSource;initial catalog=AdventureWorks*. Make sure to add "Data Source=" in front of it. The screenshot above shows the full connection string: *data source=powerbi://api.powerbi.com/v1.0/myorg/AdventureWorksSource;initial catalog=AdventureWorks*.
# Additional features
Metadata Translator v1.0 does not support connections to data models hosted in SQL Server Analysis Services, Azure Analysis Services, or the Power BI service yet. A future version will provide this capability to add translations to an online dataset.
Metadata Translator v1.1 does not support editing the default language strings because the external tools integration feature of Power BI Desktop does not support these operations yet.
It is also planned to add support for editing the default language strings as soon as the external tools integration feature of Power BI Desktop supports these operations.
It is planned to add support for command-line import and export operations so that translations can be automated.
For additional feature requests, create a new item under [Issues](https://github.com/microsoft/Analysis-Services/issues).

Просмотреть файл

@ -104,6 +104,9 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="UI\ConnectionStringInput.xaml.cs">
<DependentUpon>ConnectionStringInput.xaml</DependentUpon>
</Compile>
<Compile Include="Converters\CollectionEmptyTrueFalseConverter.cs" />
<Compile Include="Converters\TranslationPropertyToolTipConverter.cs" />
<Compile Include="Data\CsvRow.cs" />
@ -138,6 +141,10 @@
<Compile Include="Converters\TrueFalseVisibilityConverter.cs" />
<Compile Include="Translations\Translation.cs" />
<Compile Include="Translations\TranslationResult.cs" />
<Page Include="UI\ConnectionStringInput.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="UI\ImportExportPanel.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

Просмотреть файл

@ -51,5 +51,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]

Просмотреть файл

@ -22,6 +22,7 @@
<system:String x:Key="ImportExportToolTip">Opens the Import/Export pane to export and import the captions, descriptions, and display folder names via .csv files.</system:String>
<system:String x:Key="InvalidArguments">Metadata Translator cannot start without server and database arguments. Double-check the 'arguments' setting in the metadata-translator.pbitool.json file in your Microsoft Shared\Power BI Desktop\External Tools folder. The value must be: "\"%server%\" \"%database%\"".</system:String>
<system:String x:Key="DatasetConnection">Dataset Connection String</system:String>
<system:String x:Key="DatasetConnectionPrompt">Enter the connection string to the dataset.</system:String>
<system:String x:Key="SubscriptionKey">Translator Subscription Key</system:String>
<system:String x:Key="TranslatorEndpoint">Translator Endpoint</system:String>
<system:String x:Key="TranslatorLocation">Translator Location</system:String>

Просмотреть файл

@ -0,0 +1,51 @@
<UserControl x:Class="Metadata_Translator.ConnectionStringInput"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Metadata_Translator"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="{StaticResource DatasetConnection}" Margin="4,0"/>
<TextBox x:Name="ConnectionString" Grid.Row="0" Grid.Column="1" VerticalContentAlignment="Center">
<TextBox.Style>
<Style TargetType="TextBox" xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Style.Resources>
<VisualBrush x:Key="CueBrush" AlignmentX="Left" AlignmentY="Center" Stretch="None">
<VisualBrush.Visual>
<Grid>
<Rectangle Width="3000" Height="100" Fill="White"/>
<Label Content="{StaticResource DatasetConnectionPrompt}" Foreground="Gray" FontStyle="Italic" VerticalAlignment="Center"/>
</Grid>
</VisualBrush.Visual>
</VisualBrush>
</Style.Resources>
<Style.Triggers>
<Trigger Property="Text" Value="{x:Static sys:String.Empty}">
<Setter Property="Background" Value="{StaticResource CueBrush}" />
</Trigger>
<Trigger Property="Text" Value="{x:Null}">
<Setter Property="Background" Value="{StaticResource CueBrush}" />
</Trigger>
<Trigger Property="IsKeyboardFocused" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
<StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="OK" Margin="4" Width="48" Click="OKButton_Click"/>
<Button Content="Cancel" Margin="4" Width="48" Click="CancelButton_Click"/>
</StackPanel>
</Grid>
</UserControl>

Просмотреть файл

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Metadata_Translator
{
/// <summary>
/// Interaction logic for ConnectionStringInput.xaml
/// </summary>
public partial class ConnectionStringInput : UserControl
{
public ConnectionStringInput()
{
InitializeComponent();
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
var mainWnd = MainWindow.GetMainWindow(this);
if (mainWnd != null)
{
mainWnd.ConnectToDataset(ConnectionString.Text);
}
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
}
}

Просмотреть файл

@ -15,74 +15,76 @@
<local:TranslationPropertyToolTipConverter x:Key="TranslationPropertyToolTipConverter" />
</Window.Resources>
<Grid Margin="0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ToolBarPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0">
<ToolBar ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded">
<RadioButton x:Name="LanguageToggle" GroupName="PanelButtons" Height="48" Width="48"
<local:ConnectionStringInput VerticalAlignment="Center" Margin="16" Visibility="{Binding DataModel, ElementName=main, Converter={StaticResource FalseTrueVisibilityConverter}}"/>
<Grid Margin="0" Visibility="{Binding DataModel, ElementName=main, Converter={StaticResource TrueFalseVisibilityConverter}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<ToolBarPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0">
<ToolBar ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded">
<RadioButton x:Name="LanguageToggle" GroupName="PanelButtons" Height="48" Width="48"
ToolTip="{StaticResource LanguagesToolTip}"
Click="OnToggleButton_Click" Unchecked="OnToggleButton_Uncheck">
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M152.1 236.2c-3.5-12.1-7.8-33.2-7.8-33.2h-.5s-4.3 21.1-7.8 33.2l-11.1 37.5H163zM616 96H336v320h280c13.3 0 24-10.7 24-24V120c0-13.3-10.7-24-24-24zm-24 120c0 6.6-5.4 12-12 12h-11.4c-6.9 23.6-21.7 47.4-42.7 69.9 8.4 6.4 17.1 12.5 26.1 18 5.5 3.4 7.3 10.5 4.1 16.2l-7.9 13.9c-3.4 5.9-10.9 7.8-16.7 4.3-12.6-7.8-24.5-16.1-35.4-24.9-10.9 8.7-22.7 17.1-35.4 24.9-5.8 3.5-13.3 1.6-16.7-4.3l-7.9-13.9c-3.2-5.6-1.4-12.8 4.2-16.2 9.3-5.7 18-11.7 26.1-18-7.9-8.4-14.9-17-21-25.7-4-5.7-2.2-13.6 3.7-17.1l6.5-3.9 7.3-4.3c5.4-3.2 12.4-1.7 16 3.4 5 7 10.8 14 17.4 20.9 13.5-14.2 23.8-28.9 30-43.2H412c-6.6 0-12-5.4-12-12v-16c0-6.6 5.4-12 12-12h64v-16c0-6.6 5.4-12 12-12h16c6.6 0 12 5.4 12 12v16h64c6.6 0 12 5.4 12 12zM0 120v272c0 13.3 10.7 24 24 24h280V96H24c-13.3 0-24 10.7-24 24zm58.9 216.1L116.4 167c1.7-4.9 6.2-8.1 11.4-8.1h32.5c5.1 0 9.7 3.3 11.4 8.1l57.5 169.1c2.6 7.8-3.1 15.9-11.4 15.9h-22.9a12 12 0 0 1-11.5-8.6l-9.4-31.9h-60.2l-9.1 31.8c-1.5 5.1-6.2 8.7-11.5 8.7H70.3c-8.2 0-14-8.1-11.4-15.9z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FF2F7C03"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Languages}"/>
</StackPanel>
</RadioButton>
<RadioButton x:Name="SettingsToggle" GroupName="PanelButtons" Height="48" Width="48"
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M152.1 236.2c-3.5-12.1-7.8-33.2-7.8-33.2h-.5s-4.3 21.1-7.8 33.2l-11.1 37.5H163zM616 96H336v320h280c13.3 0 24-10.7 24-24V120c0-13.3-10.7-24-24-24zm-24 120c0 6.6-5.4 12-12 12h-11.4c-6.9 23.6-21.7 47.4-42.7 69.9 8.4 6.4 17.1 12.5 26.1 18 5.5 3.4 7.3 10.5 4.1 16.2l-7.9 13.9c-3.4 5.9-10.9 7.8-16.7 4.3-12.6-7.8-24.5-16.1-35.4-24.9-10.9 8.7-22.7 17.1-35.4 24.9-5.8 3.5-13.3 1.6-16.7-4.3l-7.9-13.9c-3.2-5.6-1.4-12.8 4.2-16.2 9.3-5.7 18-11.7 26.1-18-7.9-8.4-14.9-17-21-25.7-4-5.7-2.2-13.6 3.7-17.1l6.5-3.9 7.3-4.3c5.4-3.2 12.4-1.7 16 3.4 5 7 10.8 14 17.4 20.9 13.5-14.2 23.8-28.9 30-43.2H412c-6.6 0-12-5.4-12-12v-16c0-6.6 5.4-12 12-12h64v-16c0-6.6 5.4-12 12-12h16c6.6 0 12 5.4 12 12v16h64c6.6 0 12 5.4 12 12zM0 120v272c0 13.3 10.7 24 24 24h280V96H24c-13.3 0-24 10.7-24 24zm58.9 216.1L116.4 167c1.7-4.9 6.2-8.1 11.4-8.1h32.5c5.1 0 9.7 3.3 11.4 8.1l57.5 169.1c2.6 7.8-3.1 15.9-11.4 15.9h-22.9a12 12 0 0 1-11.5-8.6l-9.4-31.9h-60.2l-9.1 31.8c-1.5 5.1-6.2 8.7-11.5 8.7H70.3c-8.2 0-14-8.1-11.4-15.9z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FF2F7C03"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Languages}"/>
</StackPanel>
</RadioButton>
<RadioButton x:Name="SettingsToggle" GroupName="PanelButtons" Height="48" Width="48"
ToolTip="{StaticResource SettingsToolTip}"
Click="OnToggleButton_Click" Unchecked="OnToggleButton_Uncheck">
<StackPanel>
<Image Height="24">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M113.595,133.642l-5.932-13.169c5.655-4.151,10.512-9.315,14.307-15.209l13.507,5.118c2.583,0.979,5.469-0.322,6.447-2.904
<StackPanel>
<Image Height="24">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M113.595,133.642l-5.932-13.169c5.655-4.151,10.512-9.315,14.307-15.209l13.507,5.118c2.583,0.979,5.469-0.322,6.447-2.904
l4.964-13.103c0.47-1.24,0.428-2.616-0.117-3.825c-0.545-1.209-1.547-2.152-2.788-2.622l-13.507-5.118
c1.064-6.93,0.848-14.014-0.637-20.871l13.169-5.932c1.209-0.545,2.152-1.547,2.622-2.788c0.47-1.24,0.428-2.616-0.117-3.825
l-5.755-12.775c-1.134-2.518-4.096-3.638-6.612-2.505l-13.169,5.932c-4.151-5.655-9.315-10.512-15.209-14.307l5.118-13.507
@ -115,185 +117,186 @@
c2.756,0.106,5.091-2.022,5.21-4.781l0.437-10.189C217.847,156.659,217.375,155.366,216.478,154.389z M160.157,183.953
c-12.844-0.55-22.846-11.448-22.295-24.292c0.536-12.514,10.759-22.317,23.273-22.317c0.338,0,0.678,0.007,1.019,0.022
c12.844,0.551,22.846,11.448,22.295,24.292C183.898,174.511,173.106,184.497,160.157,183.953z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FFDEA210"/>
<GradientStop Color="#DEA210" Offset="0.992"/>
<GradientStop Color="#AADEA210" Offset="0.527"/>
<GradientStop Color="#FFDEA210" Offset="0.644"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Settings}"/>
</StackPanel>
</RadioButton>
<Separator/>
<StackPanel>
<TextBlock FontSize="9" Text="{StaticResource TranslatedProperty}" HorizontalAlignment="Center" Margin="0,4,0,-4"/>
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<StackPanel ToolTip="{StaticResource CaptionToolTip}">
<RadioButton GroupName="TranslationProperty" IsChecked="True" HorizontalAlignment="Center" Click="OnCaptionRadioButton_Click"/>
<TextBlock FontSize="8" Text="{StaticResource Caption}" Padding="2,0"/>
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FFDEA210"/>
<GradientStop Color="#DEA210" Offset="0.992"/>
<GradientStop Color="#AADEA210" Offset="0.527"/>
<GradientStop Color="#FFDEA210" Offset="0.644"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Settings}"/>
</StackPanel>
<StackPanel ToolTip="{Binding DataModel.Descriptions, ElementName=main, Converter={StaticResource TranslationPropertyToolTipConverter}, ConverterParameter={StaticResource DescriptionToolTip}}">
<RadioButton GroupName="TranslationProperty" HorizontalAlignment="Center" Click="OnDescriptionRadioButton_Click"
</RadioButton>
<Separator/>
<StackPanel>
<TextBlock FontSize="9" Text="{StaticResource TranslatedProperty}" HorizontalAlignment="Center" Margin="0,4,0,-4"/>
<StackPanel Orientation="Horizontal" Margin="0,8,0,0">
<StackPanel ToolTip="{StaticResource CaptionToolTip}">
<RadioButton GroupName="TranslationProperty" IsChecked="True" HorizontalAlignment="Center" Click="OnCaptionRadioButton_Click"/>
<TextBlock FontSize="8" Text="{StaticResource Caption}" Padding="2,0"/>
</StackPanel>
<StackPanel ToolTip="{Binding DataModel.Descriptions, ElementName=main, Converter={StaticResource TranslationPropertyToolTipConverter}, ConverterParameter={StaticResource DescriptionToolTip}}">
<RadioButton GroupName="TranslationProperty" HorizontalAlignment="Center" Click="OnDescriptionRadioButton_Click"
IsEnabled="{Binding DataModel.Descriptions, ElementName=main, Converter={StaticResource CollectionEmptyTrueFalseConverter}}"/>
<TextBlock FontSize="8" Text="{StaticResource Description}" Padding="2,0"/>
</StackPanel>
<StackPanel ToolTip="{Binding DataModel.DisplayFolders, ElementName=main, Converter={StaticResource TranslationPropertyToolTipConverter}, ConverterParameter={StaticResource DisplayFolderToolTip}}">
<RadioButton GroupName="TranslationProperty" HorizontalAlignment="Center" Click="OnDisplayFolderRadioButton_Click"
<TextBlock FontSize="8" Text="{StaticResource Description}" Padding="2,0"/>
</StackPanel>
<StackPanel ToolTip="{Binding DataModel.DisplayFolders, ElementName=main, Converter={StaticResource TranslationPropertyToolTipConverter}, ConverterParameter={StaticResource DisplayFolderToolTip}}">
<RadioButton GroupName="TranslationProperty" HorizontalAlignment="Center" Click="OnDisplayFolderRadioButton_Click"
IsEnabled="{Binding DataModel.DisplayFolders, ElementName=main, Converter={StaticResource CollectionEmptyTrueFalseConverter}}"/>
<TextBlock FontSize="8" Text="{StaticResource DisplayFolder}" Padding="2,0"/>
<TextBlock FontSize="8" Text="{StaticResource DisplayFolder}" Padding="2,0"/>
</StackPanel>
</StackPanel>
</StackPanel>
</StackPanel>
<Separator/>
<Button Height="48" Width="48" Click="OnPrepareButton_Click" Visibility="Collapsed">
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M104 224H24c-13.255 0-24 10.745-24 24v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V248c0-13.255-10.745-24-24-24zM64 472c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zM384 81.452c0 42.416-25.97 66.208-33.277 94.548h101.723c33.397 0 59.397 27.746 59.553 58.098.084 17.938-7.546 37.249-19.439 49.197l-.11.11c9.836 23.337 8.237 56.037-9.308 79.469 8.681 25.895-.069 57.704-16.382 74.757 4.298 17.598 2.244 32.575-6.148 44.632C440.202 511.587 389.616 512 346.839 512l-2.845-.001c-48.287-.017-87.806-17.598-119.56-31.725-15.957-7.099-36.821-15.887-52.651-16.178-6.54-.12-11.783-5.457-11.783-11.998v-213.77c0-3.2 1.282-6.271 3.558-8.521 39.614-39.144 56.648-80.587 89.117-113.111 14.804-14.832 20.188-37.236 25.393-58.902C282.515 39.293 291.817 0 312 0c24 0 72 8 72 81.452z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FFAF800D"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Prepare}"/>
</StackPanel>
</Button>
<Button Height="48" Width="48" Click="OnTranslateButton_Click" ToolTip="{StaticResource TranslateToolTip}">
<StackPanel>
<Image Source="..\icon.ico" Height="24"/>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Translate}"/>
</StackPanel>
</Button>
<Button Height="48" Width="48" Click="OnApplyButton_Click" ToolTip="{StaticResource ApplyToolTip}">
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M400 480H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48v352c0 26.51-21.49 48-48 48zm-204.686-98.059l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.248-16.379-6.249-22.628 0L184 302.745l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.25 16.379 6.25 22.628.001z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FF2F7C03"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Apply}"/>
</StackPanel>
</Button>
</ToolBar>
</ToolBarPanel>
<ToolBarPanel Grid.Row="0" Grid.Column="2" Margin="0">
<ToolBar ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded">
<RadioButton x:Name="ImportExportToggle" GroupName="PanelButtons" Height="48" Width="68"
<Separator/>
<Button Height="48" Width="48" Click="OnPrepareButton_Click" Visibility="Collapsed">
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M104 224H24c-13.255 0-24 10.745-24 24v240c0 13.255 10.745 24 24 24h80c13.255 0 24-10.745 24-24V248c0-13.255-10.745-24-24-24zM64 472c-13.255 0-24-10.745-24-24s10.745-24 24-24 24 10.745 24 24-10.745 24-24 24zM384 81.452c0 42.416-25.97 66.208-33.277 94.548h101.723c33.397 0 59.397 27.746 59.553 58.098.084 17.938-7.546 37.249-19.439 49.197l-.11.11c9.836 23.337 8.237 56.037-9.308 79.469 8.681 25.895-.069 57.704-16.382 74.757 4.298 17.598 2.244 32.575-6.148 44.632C440.202 511.587 389.616 512 346.839 512l-2.845-.001c-48.287-.017-87.806-17.598-119.56-31.725-15.957-7.099-36.821-15.887-52.651-16.178-6.54-.12-11.783-5.457-11.783-11.998v-213.77c0-3.2 1.282-6.271 3.558-8.521 39.614-39.144 56.648-80.587 89.117-113.111 14.804-14.832 20.188-37.236 25.393-58.902C282.515 39.293 291.817 0 312 0c24 0 72 8 72 81.452z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FFAF800D"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Prepare}"/>
</StackPanel>
</Button>
<Button Height="48" Width="48" Click="OnTranslateButton_Click" ToolTip="{StaticResource TranslateToolTip}">
<StackPanel>
<Image Source="..\icon.ico" Height="24"/>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Translate}"/>
</StackPanel>
</Button>
<Button Height="48" Width="48" Click="OnApplyButton_Click" ToolTip="{StaticResource ApplyToolTip}">
<StackPanel>
<Image Height="24" Width="32">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M400 480H48c-26.51 0-48-21.49-48-48V80c0-26.51 21.49-48 48-48h352c26.51 0 48 21.49 48 48v352c0 26.51-21.49 48-48 48zm-204.686-98.059l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.248-16.379-6.249-22.628 0L184 302.745l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.25 16.379 6.25 22.628.001z">
<GeometryDrawing.Pen>
<Pen Brush="Black" Thickness="10"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="#FF2F7C03"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource Apply}"/>
</StackPanel>
</Button>
</ToolBar>
</ToolBarPanel>
<ToolBarPanel Grid.Row="0" Grid.Column="2" Margin="0">
<ToolBar ToolBarTray.IsLocked="True" Loaded="ToolBar_Loaded">
<RadioButton x:Name="ImportExportToggle" GroupName="PanelButtons" Height="48" Width="68"
ToolTip="{StaticResource ImportExportToolTip}"
Click="OnToggleButton_Click" Unchecked="OnToggleButton_Uncheck">
<StackPanel>
<Image Height="24">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm-96 144c0 4.42-3.58 8-8 8h-8c-8.84 0-16 7.16-16 16v32c0 8.84 7.16 16 16 16h8c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-8c-26.51 0-48-21.49-48-48v-32c0-26.51 21.49-48 48-48h8c4.42 0 8 3.58 8 8v16zm44.27 104H160c-4.42 0-8-3.58-8-8v-16c0-4.42 3.58-8 8-8h12.27c5.95 0 10.41-3.5 10.41-6.62 0-1.3-.75-2.66-2.12-3.84l-21.89-18.77c-8.47-7.22-13.33-17.48-13.33-28.14 0-21.3 19.02-38.62 42.41-38.62H200c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-12.27c-5.95 0-10.41 3.5-10.41 6.62 0 1.3.75 2.66 2.12 3.84l21.89 18.77c8.47 7.22 13.33 17.48 13.33 28.14.01 21.29-19 38.62-42.39 38.62zM256 264v20.8c0 20.27 5.7 40.17 16 56.88 10.3-16.7 16-36.61 16-56.88V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8v20.8c0 35.48-12.88 68.89-36.28 94.09-3.02 3.25-7.27 5.11-11.72 5.11s-8.7-1.86-11.72-5.11c-23.4-25.2-36.28-58.61-36.28-94.09V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8zm121-159L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z">
<GeometryDrawing.Pen>
<Pen Brush="White" Thickness="8"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="Black"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource ImportExport}"/>
</StackPanel>
</RadioButton>
</ToolBar>
</ToolBarPanel>
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<local:SettingsPanel Grid.Row="0" Grid.ColumnSpan="3"
<StackPanel>
<Image Height="24">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<DrawingGroup>
<DrawingGroup.Transform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</DrawingGroup.Transform>
<DrawingGroup.Children>
<GeometryDrawing Geometry="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm-96 144c0 4.42-3.58 8-8 8h-8c-8.84 0-16 7.16-16 16v32c0 8.84 7.16 16 16 16h8c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-8c-26.51 0-48-21.49-48-48v-32c0-26.51 21.49-48 48-48h8c4.42 0 8 3.58 8 8v16zm44.27 104H160c-4.42 0-8-3.58-8-8v-16c0-4.42 3.58-8 8-8h12.27c5.95 0 10.41-3.5 10.41-6.62 0-1.3-.75-2.66-2.12-3.84l-21.89-18.77c-8.47-7.22-13.33-17.48-13.33-28.14 0-21.3 19.02-38.62 42.41-38.62H200c4.42 0 8 3.58 8 8v16c0 4.42-3.58 8-8 8h-12.27c-5.95 0-10.41 3.5-10.41 6.62 0 1.3.75 2.66 2.12 3.84l21.89 18.77c8.47 7.22 13.33 17.48 13.33 28.14.01 21.29-19 38.62-42.39 38.62zM256 264v20.8c0 20.27 5.7 40.17 16 56.88 10.3-16.7 16-36.61 16-56.88V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8v20.8c0 35.48-12.88 68.89-36.28 94.09-3.02 3.25-7.27 5.11-11.72 5.11s-8.7-1.86-11.72-5.11c-23.4-25.2-36.28-58.61-36.28-94.09V264c0-4.42 3.58-8 8-8h16c4.42 0 8 3.58 8 8zm121-159L279.1 7c-4.5-4.5-10.6-7-17-7H256v128h128v-6.1c0-6.3-2.5-12.4-7-16.9z">
<GeometryDrawing.Pen>
<Pen Brush="White" Thickness="8"/>
</GeometryDrawing.Pen>
<GeometryDrawing.Brush>
<RadialGradientBrush>
<GradientStop Color="Black"/>
</RadialGradientBrush>
</GeometryDrawing.Brush>
</GeometryDrawing>
</DrawingGroup.Children>
</DrawingGroup>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
<TextBlock FontSize="9" HorizontalAlignment="Center" Text="{StaticResource ImportExport}"/>
</StackPanel>
</RadioButton>
</ToolBar>
</ToolBarPanel>
<Grid Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="3">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<local:SettingsPanel Grid.Row="0" Grid.ColumnSpan="3"
Visibility="{Binding IsChecked, ElementName=SettingsToggle, Converter={StaticResource FalseTrueVisibilityConverter}}"/>
<local:LanguagePanel Grid.Row="1" Visibility="{Binding IsChecked, ElementName=LanguageToggle, Converter={StaticResource FalseTrueVisibilityConverter}}"
<local:LanguagePanel Grid.Row="1" Visibility="{Binding IsChecked, ElementName=LanguageToggle, Converter={StaticResource FalseTrueVisibilityConverter}}"
Languages="{Binding Languages, ElementName=main}"/>
<ScrollViewer Grid.Row="1" Grid.Column="1" HorizontalScrollBarVisibility="Auto">
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False" CanUserAddRows="False" BorderThickness="0"/>
</ScrollViewer>
<local:ImportExportPanel Grid.Row="1" Grid.Column="2" Visibility="{Binding IsChecked, ElementName=ImportExportToggle, Converter={StaticResource FalseTrueVisibilityConverter}}"/>
<ScrollViewer Grid.Row="1" Grid.Column="1" HorizontalScrollBarVisibility="Auto">
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False" CanUserAddRows="False" BorderThickness="0"/>
</ScrollViewer>
<local:ImportExportPanel Grid.Row="1" Grid.Column="2" Visibility="{Binding IsChecked, ElementName=ImportExportToggle, Converter={StaticResource FalseTrueVisibilityConverter}}"/>
</Grid>
</Grid>
</Grid>
</Window>

Просмотреть файл

@ -50,27 +50,9 @@ namespace Metadata_Translator
public MainWindow(StartupEventArgs e) : this()
{
try
if (e.Args.Length == 2)
{
if (e.Args.Length != 2)
{
throw new Exception((string)Application.Current.FindResource("InvalidArguments"));
}
else
{
PowerBIEngine = e.Args[0];
DatabaseName = e.Args[1];
}
DataModel = DataModel.Connect(PowerBIEngine, DatabaseName);
SetDependencyProperty("Languages");
InitializeDataGrid();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Application.Current.Shutdown();
ConnectToDataset(e.Args[0], e.Args[1]);
}
}
@ -89,7 +71,55 @@ namespace Metadata_Translator
}
}
/// <summary>
/// Connects to the dataset using a connection string.
/// </summary>
/// <param name="connectionString"></param>
public void ConnectToDataset(string connectionString)
{
try
{
DataModel = DataModel.Connect(connectionString);
InitTranslationUI();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
/// <summary>
/// Connects to the dataset via server and database name.
/// </summary>
/// <param name="server"></param>
/// <param name="database"></param>
public void ConnectToDataset(string server, string database)
{
try
{
DataModel = DataModel.Connect(server, database);
InitTranslationUI();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
Application.Current.Shutdown();
}
}
#region Helper functions
/// <summary>
/// Initializes the translation grid.
/// </summary>
private void InitTranslationUI()
{
PowerBIEngine = DataModel.ServerName;
DatabaseName = DataModel.DatabaseName;
SetDependencyProperty("Languages");
InitializeDataGrid();
}
/// <summary>
/// Set Dependency Properties that wrap apps ettings.
/// </summary>
@ -244,6 +274,9 @@ namespace Metadata_Translator
#endregion
#region Dependency Properties
/// <summary>
/// DataModel object
/// </summary>
public static readonly DependencyProperty DataModelProperty =
DependencyProperty.Register("DataModel", typeof(DataModel), typeof(MainWindow));

Просмотреть файл

@ -4,94 +4,5 @@ Metadata Translator helps to streamline the localization of Power BI data models
![MetadataTranslator](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/MetadataTranslator.png)
## Installation
Metadata Translator can be installed by using a Windows Installer Package (.msi) file. The Metadata Translator solution includes a Metadata Translator Setup project to build this .msi file.
<img src="https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Installing%20Metadata%20Translator.png" alt="Installing Metadata Translator" style="zoom:50%;" />
Start the installation by launching the .msi file, accept the default settings or change the installation folder if desired, and then confirm the remaining prompts to complete the installation. To remove Metadata Translator, launch the .msi file again and choose Remove Metadata Translator, or use Add/Remove Programs.
## Starting Metadata Translator
Metadata Translator integrates with Power BI Desktop as an external tool. To start it, open a Power BI Desktop (.pbix) file, switch to the External Tools ribbon, and click on Metadata Translator. Metadata Translator automatically connects to the dataset insides the .pbix file and lets you apply changes to this dataset.
<img src="https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Launching%20Metadata%20Translator.png" alt="Launching Metadata Translator" style="zoom:38%;" />
## Configuration settings
Metadata Translator uses the cloud-based machine translation services of Azure Cognitive Services and requires a subscription key and an endpoint URL to call the Translator REST API. See [Create a Translator resource](https://docs.microsoft.com/azure/cognitive-services/Translator/translator-how-to-signup) in the product documentation. To get started, you'll need an active Azure account. If you don't have one, you can create a free 12-month subscription. For the purposes of Metadata Translator, it is also sufficient to create a free Translator instance in most cases. See [Cognitive Services pricing—Translator](https://azure.microsoft.com/pricing/details/cognitive-services/translator/) for more details.
To register a Translator instance in Metadata Translator, click on the Settings button in the toolbar and provide the required information, which is generated when you provision the Translator resource in the Azure portal. Enable the Overwrite Translation checkbox if you want to replace all existing translations every time you click on Translate.
<img src="https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Settings.png" alt="Settings" style="zoom:38%;" />
> **Note**
>
> Configuring Metadata Translator to use Azure Cognitive Services is optional. The configuration is recommended but not required if you prefer to translate the strings manually.
## Choosing languages
Metadata Translator enables you to choose from over 300 cultures in all languages that Power BI supports. Click on Languages to pick the cultures you want to add to your dataset. Although there is theoretically no limit regarding the number of cultures you can add, it is important to keep in mind that every translation increases the size of the dataset.
![Adding languages](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Adding%20languages.png)
For every language selected in the Language pane, Metadata Translator adds a column to the translation grid. Deselecting a language removes the corresponding translation grid column.
> **Note**
>
> You cannot remove the default language of the dataset, which is the language marked with an asterisk in the translation grid.
## Performing a machine translation
Having added a new language, click on the Translate button in the toolbar to fill the corresponding column in the translation grid with the translated strings. If you havent registered a translation service endpoint yet, Metadata Translator automatically opens the Settings pane for you to provide the required configuration settings. See Configuration settings earlier in this readme.
![Translate](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Translate.png)
## Reviewing translated strings
The translation grid organizes the translation based on the translated property. Choose Caption, Description, or Display Folder in the toolbar. If the current dataset does not include any descriptions or display folders, the corresponding radio buttons are greyed out.
## Editing translated strings
The translation grid also lets you add translated strings and edit any existing strings manually. Just double-click the desired grid cell and make the changes.
> **Note**
>
> You cannot edit the strings of the default language. The default language, marked with an asterisk, is read-only in the translation grid.
## Exporting to .CSV files
A dataset typically includes hundreds of strings. For convenient bulk editing in Excel or a localization tool, click on Import/Export to open the Import/Export pane, and then click Export. Be aware that Metadata Translators overwrites any existing files in the export folder without warning. It is recommended to create a new folder for each export to avoid accidental overwrites.![Export](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Export.png)
> **Note**
>
> Metadata Translators exports each culture into a separate .csv file based on the locale identifier (LCID).
## Importing from .CSV files
To import translated strings from a .csv file, make sure the file name(s) correspond(s) to the locale identifier (LCID) of the target language(s). Click on Import/Export to open the Import/Export pane, and then click Import. Choose the files in the Open dialog box and click Open.
![Import](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Import.png)
If you import a .csv file for a culture that you havent added to the dataset yet, Metadata Translator automatically adds the culture for you and displays the corresponding column in the translation grid with the imported strings.
> **Note**
>
> During the import operation, Metadata Translators first expects a full match of the default strings including their ordering. If the ordering is different, Metadata Translators switches to case-sensitive string matching. Any strings that dont have an exact match are ignored and the corresponding cells remain empty in the translation grid.
## Applying translations to a dataset
Metadata Translator detects the default language and all translations in the dataset and reads corresponding the captions, descriptions, and display folder names on startup. As you work with the translation grid, add or remove cultures, perform machine translations, or import translated strings, the changes only affect the data in Metadata Translator. To apply the changes to the dataset, click on the Apply button in the toolbar, and then save the .pbix file in Power BI Desktop to persist the changes.
![Applying translations](https://github.com/microsoft/Analysis-Services/blob/master/MetadataTranslator/Metadata%20Translator/Documentation/Images/Applying%20translations.png)
# Additional features
Metadata Translator v1.0 does not support connections to data models hosted in SQL Server Analysis Services, Azure Analysis Services, or the Power BI service yet. A future version will provide this capability to add translations to an online dataset.
It is also planned to add support for editing the default language strings as soon as the external tools integration feature of Power BI Desktop supports these operations.
For additional feature requests, create a new item under [Issues](https://github.com/microsoft/Analysis-Services/issues).
[Metadata Translator Documentation](Metadata%20Translator/Documentation/README.md)