Internal/Invoke-PrintTableTranslate.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
Function Invoke-PrintTableTranslate(){
<#
    .SYNOPSIS
    This function is used to print the configuration with translation to the word file.
    .EXAMPLE
    Invoke-TableTranslate -Properties $p -TypeName $t
    Prints the information from the Config Array
    .NOTES
    NAME: Invoke-TableTranslate
    #>

    param(
        [Parameter(Mandatory=$true)]
        $Properties,
        [Parameter(Mandatory=$true)]
        [String]$TypeName
    )
    $MaxStringLengthSettings = 350
    $ht = @{}
    $TranslationFile = "$PSScriptRoot\..\Data\LabelTranslation\$TypeName.json"

    $translateJson = Get-Content $TranslationFile -ErrorAction SilentlyContinue
    if($null -eq $translateJson){
        $translateJson = "{}"
    }
    $translation = $translateJson | ConvertFrom-Json

    foreach($p in $Properties) {   
        if([String]::IsNullOrWhiteSpace($translation."$($p.Name)")){
            $TranslationValue = switch($p.Name){
                "displayName" { "Displayname" }
                "lastModifiedDateTime" { "Modified at" }
                "@odata.type" { "OData Type" }
                "supportsScopeTags" { "Support for Scope Tags" }
                "roleScopeTagIds" {  "Role Scopes Tags" }
                "deviceManagementApplicabilityRuleOsEdition" {  "Applicability OS Edition" }
                "deviceManagementApplicabilityRuleOsVersion" {  "Applicability OS Version" }
                "deviceManagementApplicabilityRuleDeviceMode" {  "Applicability Device Mode" }
                "createdDateTime" {  "Created at" }
                "description" {  "Description" }
                "version" {  "Version" }
                "id" {'ID'}
                default { '' }   
            }
            if([String]::IsNullOrWhiteSpace($TranslationValue)){
                $Section = " "
            } else {
                $Section = "Metadata"
            }

            if($p.TypeNameOfValue -eq "System.Boolean"){
                $TranslationObject = New-Object PSObject -Property @{
                    Name = $TranslationValue
                    Section = $Section
                    DataType = $p.TypeNameOfValue
                    ValueTrue = "Block"
                    ValueFalse = "Not Configured"
                }
            } else {
                $TranslationObject = New-Object PSObject -Property @{
                    Name = $TranslationValue
                    Section = $Section
                    DataType = $p.TypeNameOfValue
                }
            }
            #Only use translated value if not empty
            if([String]::IsNullOrWhiteSpace($TranslationValue)){
                $Name = Convert-CamelCaseToDisplayName -Value $p.Name
            } else {
                $Name = $TranslationValue
            }
            $translation | Add-Member Noteproperty -Name $p.Name -Value $TranslationObject -Force 
            $translation | ConvertTo-Json | Out-File -FilePath $TranslationFile -Force
            #Variable set for user information in main function
            $Script:NewTranslationFiles += $TranslationFile
        } else { 
            #Only use translated value if not empty
            if([String]::IsNullOrWhiteSpace($translation."$($p.Name)".Name)){
                $Name = $p.Name
            } else {
                $Name = $translation."$($p.Name)".Name
            }
            
        }
        
        # Value
        if($p.TypeNameOfValue -eq "System.Boolean"){
            if([String]::IsNullOrWhiteSpace($translation."$($p.Name)".Name)){
                $Value = $p.Value
            } else {
                if($p.Value -eq $true){
                    $Value = $translation."$($p.Name)".ValueTrue
                } else {
                    $Value = $translation."$($p.Name)".ValueFalse
                }
            }
        } else {
            if((Format-MsGraphData "$($p.Value)").Length -gt $MaxStringLengthSettings){
                $Value = "$((Format-MsGraphData "$($p.Value)").substring(0, $MaxStringLengthSettings))..."
            } else {
                $Value = "$((Format-MsGraphData "$($p.Value)")) "
            }
        }
        if($null -eq $Value){
            $Value = ""
        }
        $ht[$Name] = $Value
    }
    ($ht.GetEnumerator() | Sort-Object -Property Name | Select-Object Name,Value) | Add-WordTable -FilePath $FullDocumentationPath -AutoFitStyle Window -Design LightListAccent2
}
# SIG # Begin signature block
# MIIPGgYJKoZIhvcNAQcCoIIPCzCCDwcCAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUx+YK6dYjey1dmVbAksY40k9I
# 52egggxqMIIFrTCCBJWgAwIBAgIQBD9LZ/ZeEn/YHaINoG/0ljANBgkqhkiG9w0B
# AQUFADBlMQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYD
# VQQLExB3d3cuZGlnaWNlcnQuY29tMSQwIgYDVQQDExtEaWdpQ2VydCBFViBDb2Rl
# IFNpZ25pbmcgQ0EwHhcNMjAwMzA2MDAwMDAwWhcNMjMwMzE1MTIwMDAwWjCBzjET
# MBEGCysGAQQBgjc8AgEDEwJDSDEaMBgGCysGAQQBgjc8AgECEwlTb2xvdGh1cm4x
# HTAbBgNVBA8MFFByaXZhdGUgT3JnYW5pemF0aW9uMRgwFgYDVQQFEw9DSEUtMzE0
# LjYzOS41MjMxCzAJBgNVBAYTAkNIMRIwEAYDVQQIEwlTb2xvdGh1cm4xETAPBgNV
# BAcMCETDpG5pa2VuMRYwFAYDVQQKEw1iYXNlVklTSU9OIEFHMRYwFAYDVQQDEw1i
# YXNlVklTSU9OIEFHMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAp9MW
# Qk/Mk+vNR2VWPILVJVESssMvDX6vLor/4ySVPv03+Bx11ycx6PemRaP1jljA91jF
# kWEZ6Y/eT2W3y2hfpIvz1EUYaff6E/6eTt807+Cap4oOwDniC+XbfVuVIo/awzhG
# YZhaVU9PCgioTDTDLuzIQbPrhwZckO9I+R9iIwY3j7RA2HGpG79UTQyuYVPpNlKi
# mREEmqrdvq4nsMUtkeEVL2SeZ0a2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