mirror of
https://github.com/Nikolay-Shirokov/cc-1c-skills.git
synced 2026-06-10 08:04:56 +03:00
feat(skd-compile): multilang static text в ячейках шаблона
Get-CellValue теперь пропускает dict без ключа value (multilang dict
{ru, en, ...}), а главный цикл Emit-Templates эмитит для таких ячеек
<dcsat:item xsi:type="dcsat:Field"><dcsat:value xsi:type="v8:LocalStringType">
с lwsTitle-структурой. Раньше multilang-ячейки терялись (Get-CellValue
возвращал null → cell не эмитился).
sample30: −180 строк (2870 → 2690).
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# skd-compile v1.68 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.69 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
param(
|
||||
[string]$DefinitionFile,
|
||||
@@ -1698,7 +1698,13 @@ function Get-CellValue {
|
||||
param($cell)
|
||||
if ($null -eq $cell) { return $null }
|
||||
if ($cell -is [string]) { return $cell }
|
||||
if ($cell -is [hashtable] -or $cell -is [System.Collections.IDictionary]) {
|
||||
if ($cell.Contains('value')) { return $cell['value'] }
|
||||
return $cell # multilang dict без обёртки
|
||||
}
|
||||
if ($cell.PSObject -and $cell.PSObject.Properties['value']) { return $cell.value }
|
||||
# PSCustomObject без 'value' — это multilang dict ({ru, en, ...}), отдаём как есть
|
||||
if ($cell -is [PSCustomObject]) { return $cell }
|
||||
return $null
|
||||
}
|
||||
|
||||
@@ -1779,7 +1785,14 @@ function Emit-AreaTemplateDSL {
|
||||
Emit-CellAppearance $cellStyle $w $false $true
|
||||
} else {
|
||||
# Cell value
|
||||
if ($null -ne $cellVal -and $cellVal -ne '') {
|
||||
$cellIsDict = ($cellVal -is [hashtable]) -or ($cellVal -is [System.Collections.IDictionary]) -or ($cellVal -is [PSCustomObject])
|
||||
if ($cellIsDict) {
|
||||
# Multilang static text — эмитим напрямую с lwsTitle-подобной структурой
|
||||
X "`t`t`t`t`t<dcsat:item xsi:type=`"dcsat:Field`">"
|
||||
Emit-MLText -tag "dcsat:value" -text $cellVal -indent "`t`t`t`t`t`t"
|
||||
X "`t`t`t`t`t</dcsat:item>"
|
||||
$cellExtraItems = @()
|
||||
} elseif ($null -ne $cellVal -and $cellVal -ne '') {
|
||||
$cellStr = "$cellVal"
|
||||
# Unescape \| and \>
|
||||
if ($cellStr -eq '\|') { $cellStr = '|' }
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
# skd-compile v1.68 — Compile 1C DCS from JSON
|
||||
# skd-compile v1.69 — Compile 1C DCS from JSON
|
||||
# Source: https://github.com/Nikolay-Shirokov/cc-1c-skills
|
||||
import argparse
|
||||
import json
|
||||
@@ -1405,8 +1405,10 @@ def _get_cell_value(cell):
|
||||
return None
|
||||
if isinstance(cell, str):
|
||||
return cell
|
||||
if isinstance(cell, dict) and 'value' in cell:
|
||||
return cell['value']
|
||||
if isinstance(cell, dict):
|
||||
if 'value' in cell:
|
||||
return cell['value']
|
||||
return cell # multilang dict without wrapper
|
||||
return None
|
||||
|
||||
|
||||
@@ -1478,7 +1480,12 @@ def _emit_area_template_dsl(lines, t):
|
||||
_emit_cell_appearance(lines, cell_style, w, h_merge=True)
|
||||
else:
|
||||
cell_extra_items = []
|
||||
if cell_val is not None and str(cell_val) != '':
|
||||
if isinstance(cell_val, dict):
|
||||
# Multilang static text — эмитим напрямую
|
||||
lines.append('\t\t\t\t\t<dcsat:item xsi:type="dcsat:Field">')
|
||||
emit_mltext(lines, '\t\t\t\t\t\t', 'dcsat:value', cell_val)
|
||||
lines.append('\t\t\t\t\t</dcsat:item>')
|
||||
elif cell_val is not None and str(cell_val) != '':
|
||||
cell_str = str(cell_val)
|
||||
# Unescape \| and \>
|
||||
if cell_str == '\\|':
|
||||
|
||||
Reference in New Issue
Block a user