SetupTranslationsTable
Manages a translations ListObject backed by a helper tag column. Synchronises translations from a watcher registry, handles language column creation and promotion, removes obsolete and duplicate labels, reports missing and duplicate entries, and exports the table to external workbooks. Uses HiddenNames for sequence counters.
Factory helpers
Create #
create
Create a configured translations table manager instance.
Signature:
Public Function Create(ByVal translationTable As ListObject, Optional ByVal stateScope As IApplicationState = Nothing) As ISetupTranslationsTable
Parameters:
translationTable: ListObject. The managed translations table.stateScope: Optional IApplicationState. Guard for Excel settings during updates.
Returns: ISetupTranslationsTable. Ready to process registry updates.
Internal members (not exported)
Factory helpers
InitialiseCore #
initialise-core
Store the supplied table and optional scope inside the current instance.
Signature:
Public Sub InitialiseCore(ByVal translationTable As ListObject, Optional ByVal stateScope As IApplicationState = Nothing)
Public configuration
HostWorksheet #
host-worksheet
Worksheet hosting the translations table.
Signature:
Public Property Get HostWorksheet() As Worksheet
TableName #
table-name
Name of the managed translations ListObject.
Signature:
Public Property Get TableName() As String
Self #
self
Self reference used by factories returning interface instances.
Signature:
Public Property Get Self() As ISetupTranslationsTable
SetDisplayPrompts #
set-display-prompts
Allow callers to toggle display prompts used during updates.
Signature:
Public Sub SetDisplayPrompts(ByVal state As Boolean)
ResolveScope #
resolve-scope
Guarded access to the application scope.
Signature:
Private Function ResolveScope() As IApplicationState
Language management
EnsureLanguages #
ensure-languages
Ensure all provided languages exist as table headers.
Signature:
Private Sub EnsureLanguages(Optional ByVal lang As String = vbNullString)
TryGetWrittenLanguages #
try-get-written-languages
Collect language names written to the right of the table.
Signature:
Private Function TryGetWrittenLanguages(ByRef languages As String, ByVal newLang As String) As Boolean
EnsureLanguageColumn #
ensure-language-column
Create the language column when it does not exist.
Signature:
Private Sub EnsureLanguageColumn(ByVal languageName As String)
PersistLanguageList #
persist-language-list
Persist the available languages into the worksheet hidden names.
Signature:
Private Sub PersistLanguageList()
SwitchDefaultLanguage #
switch-default-language
Promote the requested language column to become the primary language.
Signature:
Public Sub SwitchDefaultLanguage(ByVal languageName As String)
SwitchableLanguages #
switchable-languages
Retrieve the available languages excluding the default column.
Signature:
Public Function SwitchableLanguages() As BetterArray
Languages #
languages
Languages available for translation excluding the default column unless requested.
Signature:
Public Property Get Languages(Optional ByVal includeDefault As Boolean = False) As BetterArray
Language utilities
DefaultLanguageHeader #
default-language-header
Resolve the current default language header.
Signature:
Private Function DefaultLanguageHeader() As String
LanguageColumnIndex #
language-column-index
Resolve the column index for a provided language header.
Signature:
Private Function LanguageColumnIndex(ByVal languageName As String) As Long
ResolveLanguageColumn #
resolve-language-column
Resolve the data body range for a given language column.
Signature:
Private Function ResolveLanguageColumn(ByVal languageName As String) As Range
SwapLanguageColumns #
swap-language-columns
Swap the headers, data, and totals between two language columns.
Signature:
Private Sub SwapLanguageColumns(ByVal firstIndex As Long, ByVal secondIndex As Long)
UniqueTemporaryHeader #
unique-temporary-header
Generate a temporary header that does not collide with existing columns.
Signature:
Private Function UniqueTemporaryHeader() As String
SwapCellContents #
swap-cell-contents
Swap the formula and number format between two cells.
Signature:
Private Sub SwapCellContents(ByVal leftCell As Range, ByVal rightCell As Range)
Registry processing
ResetSequence #
reset-sequence
Reset the hidden update sequence counter to zero.
Signature:
Public Sub ResetSequence(ByVal registrySheet As Worksheet)
UpdateFromRegistry #
update-from-registry
Update the translations table using the supplied registry sheet.
Signature:
Public Sub UpdateFromRegistry(ByVal registrySheet As Worksheet, _
Optional ByVal languages As String = vbNullString)
ProcessRegistry #
process-registry
Iterate all registry tables and process each watcher row.
Signature:
Private Sub ProcessRegistry(ByVal registrySheet As Worksheet, ByVal updateSequence As Long)
ProcessRegistryTable #
process-registry-table
Process a single registry ListObject.
Signature:
Private Sub ProcessRegistryTable(ByVal registryTable As ListObject, ByVal updateSequence As Long)
ShouldProcessRange #
should-process-range
Determine whether the named range should be processed this cycle.
Signature:
Private Function ShouldProcessRange(ByVal status As String, ByVal updateSequence As Long) As Boolean
ProcessSourceRange #
process-source-range
Dispatch processing based on the requested translation mode.
Signature:
Private Sub ProcessSourceRange(ByVal sourceRange As Range, ByVal rngTag As String, ByVal mode As String)
ProcessTextRange #
process-text-range
Add literal cell values to the translations table.
Signature:
Private Sub ProcessTextRange(ByVal sourceRange As Range, ByVal rngTag As String)
ProcessFormulaRange #
process-formula-range
Extract quoted portions of formulas and add them as chunks.
Signature:
Private Sub ProcessFormulaRange(ByVal sourceRange As Range, ByVal rngTag As String)
ExtractFormulaChunks #
extract-formula-chunks
Extract quoted text segments from a formula while handling escaped quotes.
Signature:
Private Function ExtractFormulaChunks(ByVal formulaText As String) As BetterArray
Chunk management
AddChunk #
add-chunk
Add or update a translation chunk in the table.
Signature:
Private Sub AddChunk(ByVal label As String, ByVal rngTag As String)
AppendRow #
append-row
Append a new list row and populate the mandatory cells.
Signature:
Private Function AppendRow(ByVal label As String, ByVal rngTag As String) As Long
Label buffer
InitLabelBuffer #
init-label-buffer
Read the label column into a 1D in-memory buffer for lookups.
Signature:
Private Sub InitLabelBuffer()
FindLabelRow #
find-label-row
Find the row index for a label using a simple linear scan of the label buffer.
Signature:
Private Function FindLabelRow(ByVal label As String) As Long
Tag buffer
InitTagBuffer #
init-tag-buffer
Read the tag column into a 1D in-memory buffer for batch writes.
Signature:
Private Sub InitTagBuffer()
FlushTagBuffer #
flush-tag-buffer
Write the accumulated tag buffer back to the tag column in one operation.
Signature:
Private Sub FlushTagBuffer()
Process tracking
TrackProcessedRange #
track-processed-range
Track the ranges processed during the current registry cycle.
Signature:
Private Sub TrackProcessedRange(ByVal rngName As String)
WasRangeProcessed #
was-range-processed
Determine whether a registry range was processed during the active cycle.
Signature:
Private Function WasRangeProcessed(ByVal rngName As String) As Boolean
ResetProcessedRanges #
reset-processed-ranges
Reset processed ranges tracking.
Signature:
Private Sub ResetProcessedRanges()
RemoveObsoleteLabels #
remove-obsolete-labels
Remove labels whose source ranges were processed but whose tags are stale.
Signature:
Private Sub RemoveObsoleteLabels(ByVal updateSequence As Long)
DeduplicateLabels #
deduplicate-labels
Remove duplicate labels keeping the row with the oldest (lowest) tag sequence.
Signature:
Private Sub DeduplicateLabels()
SortIndicesDescending #
sort-indices-descending
Sort a 1-based Long array in descending order (simple insertion sort).
Signature:
Private Sub SortIndicesDescending(ByRef arr() As Long, ByVal count As Long)
ParseTag #
parse-tag
Parse helper tag text into its components.
Signature:
Private Function ParseTag(ByVal tagText As String, ByRef rangeName As String, ByRef sequenceValue As Long) As Boolean
CreateBuffer #
create-buffer
Create a BetterArray buffer with deterministic bounds.
Signature:
Private Function CreateBuffer() As BetterArray
BuildDuplicateLine #
build-duplicate-line
Format a single duplicate-count line for reporting.
Signature:
Private Function BuildDuplicateLine(ByVal labelValue As String, ByVal occurrenceCount As Long) As String
Reporting
MissingLabels #
missing-labels
Count missing translation labels for a specific language.
Signature:
Private Function MissingLabels(ByVal lang As String) As Long
NumberOfMissing #
number-of-missing
Summarise missing translations per language and optionally prompt the user.
Signature:
Private Function NumberOfMissing() As String
UpdateMissingSummary #
update-missing-summary
Update internal missing summary.
Signature:
Private Sub UpdateMissingSummary(ByVal summary As BetterArray)
InternalMissingSummary #
internal-missing-summary
Cached missing-labels summary across languages.
Signature:
Private Property Get InternalMissingSummary() As BetterArray
UpdateDuplicatesSummary #
update-duplicates-summary
Build duplicate summary for every language column.
Signature:
Private Sub UpdateDuplicatesSummary()
InternalDuplicatesSummary #
internal-duplicates-summary
Cached duplicates summary across languages.
Signature:
Private Property Get InternalDuplicatesSummary() As BetterArray
DuplicateLabels #
duplicate-labels
Report duplicate translation labels when they exist.
Signature:
Private Function DuplicateLabels(ByRef duplicateMessage As String, Optional ByVal languageName As String = vbNullString) As Boolean
ComputeDuplicateSummary #
compute-duplicate-summary
Compute duplicates for one language or all languages using simple linear counting.
Signature:
Private Function ComputeDuplicateSummary(ByVal languageName As String) As TDuplicateSummary
LabelColumnData #
label-column-data
Access the label column data range.
Signature:
Private Function LabelColumnData() As Range
Tag column infrastructure
TagColumnDataRange #
tag-column-data-range
Retrieve the helper tag column data range.
Signature:
Private Function TagColumnDataRange() As Range
ApplyTagColumnFormatting #
apply-tag-column-formatting
Ensure the helper column keeps its stealth formatting regardless of state.
Signature:
Private Sub ApplyTagColumnFormatting()
ApplyLangColumnFormatting #
apply-lang-column-formatting
Apply font, sizing, and duplicate highlighting to a language column.
Signature:
Private Sub ApplyLangColumnFormatting(ByVal langRng As Range)
ConfigureTagColumn #
configure-tag-column
Ensure the helper column header is located and configured.
Signature:
Private Sub ConfigureTagColumn()
EnsureTagColumnReady #
ensure-tag-column-ready
Verify the helper tag column is accessible.
Signature:
Private Sub EnsureTagColumnReady()
RequireTagHeader #
require-tag-header
Return the tag header cell, raising an error when unavailable.
Signature:
Private Function RequireTagHeader() As Range
AttachTagHeader #
attach-tag-header
Attempt to reconfigure and attach the tag header cell.
Signature:
Private Sub AttachTagHeader()
IsRangeValid #
is-range-valid
Test whether a Range reference is still alive and readable.
Signature:
Private Function IsRangeValid(ByVal candidate As Range) As Boolean
Tag integration helpers
BeginTagIntegration #
begin-tag-integration
Temporarily include the helper tag column inside the managed table.
Signature:
Private Sub BeginTagIntegration()
EndTagIntegration #
end-tag-integration
Restore the translations table to exclude the helper tag column.
Signature:
Private Sub EndTagIntegration()
LabelColumnIndex #
label-column-index
Resolve the current column index storing translation labels.
Signature:
Private Function LabelColumnIndex() As Long
Sorting and formatting
SortTranslations #
sort-translations
Sort the translations by their primary language column.
Signature:
Private Sub SortTranslations()
ApplyFormatting #
apply-formatting
Apply light formatting and duplicate highlighting once per update.
Signature:
Private Sub ApplyFormatting()
Data exchange
Export #
export
Export translations into a destination workbook.
Signature:
Public Sub Export(ByVal exportWorkbook As Workbook, Optional ByVal Hide As Long = xlSheetVisible)
Registry bookkeeping
NextUpdateSequence #
next-update-sequence
Retrieve and increment the registry update sequence.
Signature:
Private Function NextUpdateSequence(ByVal registrySheet As Worksheet) As Long
PersistCounterValue #
persist-counter-value
Persist the counter value inside a hidden worksheet-level name.
Signature:
Private Sub PersistCounterValue(ByVal registrySheet As Worksheet, ByVal counterValue As Long)
CounterNumericValue #
counter-numeric-value
Retrieve the current counter value stored in worksheet names.
Signature:
Private Function CounterNumericValue(ByVal registrySheet As Worksheet) As Long
HiddenNameStore #
hidden-name-store
Create a HiddenNames wrapper for the supplied registry sheet.
Signature:
Private Function HiddenNameStore(ByVal registrySheet As Worksheet) As IHiddenNames
MetadataStore #
metadata-store
Resolve the hidden name store hosting metadata.
Signature:
Private Function MetadataStore() As IHiddenNames
Validation and utilities
ValidateInitialised #
validate-initialised
Ensure the manager has been initialised before use.
Signature:
Private Sub ValidateInitialised()
ValidateTranslationTable #
validate-translation-table
Validate the supplied translations table.
Signature:
Private Sub ValidateTranslationTable(ByVal translationTable As ListObject)
ValidateRegistrySheet #
validate-registry-sheet
Validate the registry sheet before processing.
Signature:
Private Sub ValidateRegistrySheet(ByVal registrySheet As Worksheet)
ResolveNamedRange #
resolve-named-range
Resolve a named range from the workbook, returning Nothing when missing.
Signature:
Private Function ResolveNamedRange(ByVal hostwb As Workbook, ByVal rangeName As String) As Range
ThrowProjectError #
throw-project-error
Raise a project error with a contextual message.
Signature:
Private Sub ThrowProjectError(ByVal errNumber As ProjectError, ByVal message As String)
Interface implementation
ISetupTranslationsTable_EnsureLanguages #
Signature:
Private Sub ISetupTranslationsTable_EnsureLanguages(Optional ByVal languages As String = vbNullString)
Thin delegation stubs wiring ISetupTranslationsTable members to the corresponding public or private methods on this class.
ISetupTranslationsTable_Initialise #
initialise
Signature:
Private Sub ISetupTranslationsTable_Initialise(ByVal translationTable As ListObject, Optional ByVal stateScope As IApplicationState)