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 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

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

host-worksheet #

Worksheet hosting the translations table.

Signature:

Public Property Get HostWorksheet() As Worksheet

table-name #

Name of the managed translations ListObject.

Signature:

Public Property Get TableName() As String

self #

Self reference used by factories returning interface instances.

Signature:

Public Property Get Self() As ISetupTranslationsTable

set-display-prompts #

Allow callers to toggle display prompts used during updates.

Signature:

Public Sub SetDisplayPrompts(ByVal state As Boolean)

resolve-scope #

Guarded access to the application scope.

Signature:

Private Function ResolveScope() As IApplicationState

Language management

ensure-languages #

Ensure all provided languages exist as table headers.

Signature:

Private Sub EnsureLanguages(Optional ByVal lang As String = vbNullString)

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

ensure-language-column #

Create the language column when it does not exist.

Signature:

Private Sub EnsureLanguageColumn(ByVal languageName As String)

persist-language-list #

Persist the available languages into the worksheet hidden names.

Signature:

Private Sub PersistLanguageList()

switch-default-language #

Promote the requested language column to become the primary language.

Signature:

Public Sub SwitchDefaultLanguage(ByVal languageName As String)

switchable-languages #

Retrieve the available languages excluding the default column.

Signature:

Public Function SwitchableLanguages() As BetterArray

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

default-language-header #

Resolve the current default language header.

Signature:

Private Function DefaultLanguageHeader() As String

language-column-index #

Resolve the column index for a provided language header.

Signature:

Private Function LanguageColumnIndex(ByVal languageName As String) As Long

resolve-language-column #

Resolve the data body range for a given language column.

Signature:

Private Function ResolveLanguageColumn(ByVal languageName As String) As Range

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)

unique-temporary-header #

Generate a temporary header that does not collide with existing columns.

Signature:

Private Function UniqueTemporaryHeader() As String

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

reset-sequence #

Reset the hidden update sequence counter to zero.

Signature:

Public Sub ResetSequence(ByVal registrySheet As Worksheet)

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)

process-registry #

Iterate all registry tables and process each watcher row.

Signature:

Private Sub ProcessRegistry(ByVal registrySheet As Worksheet, ByVal updateSequence As Long)

process-registry-table #

Process a single registry ListObject.

Signature:

Private Sub ProcessRegistryTable(ByVal registryTable As ListObject, ByVal updateSequence As Long)

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

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)

process-text-range #

Add literal cell values to the translations table.

Signature:

Private Sub ProcessTextRange(ByVal sourceRange As Range, ByVal rngTag As String)

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)

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

add-chunk #

Add or update a translation chunk in the table.

Signature:

Private Sub AddChunk(ByVal label As String, ByVal rngTag As String)

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

init-label-buffer #

Read the label column into a 1D in-memory buffer for lookups.

Signature:

Private Sub InitLabelBuffer()

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

init-tag-buffer #

Read the tag column into a 1D in-memory buffer for batch writes.

Signature:

Private Sub InitTagBuffer()

flush-tag-buffer #

Write the accumulated tag buffer back to the tag column in one operation.

Signature:

Private Sub FlushTagBuffer()

Process tracking

track-processed-range #

Track the ranges processed during the current registry cycle.

Signature:

Private Sub TrackProcessedRange(ByVal rngName As String)

was-range-processed #

Determine whether a registry range was processed during the active cycle.

Signature:

Private Function WasRangeProcessed(ByVal rngName As String) As Boolean

reset-processed-ranges #

Reset processed ranges tracking.

Signature:

Private Sub ResetProcessedRanges()

remove-obsolete-labels #

Remove labels whose source ranges were processed but whose tags are stale.

Signature:

Private Sub RemoveObsoleteLabels(ByVal updateSequence As Long)

deduplicate-labels #

Remove duplicate labels keeping the row with the oldest (lowest) tag sequence.

Signature:

Private Sub DeduplicateLabels()

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)

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

create-buffer #

Create a BetterArray buffer with deterministic bounds.

Signature:

Private Function CreateBuffer() As BetterArray

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

missing-labels #

Count missing translation labels for a specific language.

Signature:

Private Function MissingLabels(ByVal lang As String) As Long

number-of-missing #

Summarise missing translations per language and optionally prompt the user.

Signature:

Private Function NumberOfMissing() As String

update-missing-summary #

Update internal missing summary.

Signature:

Private Sub UpdateMissingSummary(ByVal summary As BetterArray)

internal-missing-summary #

Cached missing-labels summary across languages.

Signature:

Private Property Get InternalMissingSummary() As BetterArray

update-duplicates-summary #

Build duplicate summary for every language column.

Signature:

Private Sub UpdateDuplicatesSummary()

internal-duplicates-summary #

Cached duplicates summary across languages.

Signature:

Private Property Get InternalDuplicatesSummary() As BetterArray

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

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

label-column-data #

Access the label column data range.

Signature:

Private Function LabelColumnData() As Range

Tag column infrastructure

tag-column-data-range #

Retrieve the helper tag column data range.

Signature:

Private Function TagColumnDataRange() As Range

apply-tag-column-formatting #

Ensure the helper column keeps its stealth formatting regardless of state.

Signature:

Private Sub ApplyTagColumnFormatting()

apply-lang-column-formatting #

Apply font, sizing, and duplicate highlighting to a language column.

Signature:

Private Sub ApplyLangColumnFormatting(ByVal langRng As Range)

configure-tag-column #

Ensure the helper column header is located and configured.

Signature:

Private Sub ConfigureTagColumn()

ensure-tag-column-ready #

Verify the helper tag column is accessible.

Signature:

Private Sub EnsureTagColumnReady()

require-tag-header #

Return the tag header cell, raising an error when unavailable.

Signature:

Private Function RequireTagHeader() As Range

attach-tag-header #

Attempt to reconfigure and attach the tag header cell.

Signature:

Private Sub AttachTagHeader()

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

begin-tag-integration #

Temporarily include the helper tag column inside the managed table.

Signature:

Private Sub BeginTagIntegration()

end-tag-integration #

Restore the translations table to exclude the helper tag column.

Signature:

Private Sub EndTagIntegration()

label-column-index #

Resolve the current column index storing translation labels.

Signature:

Private Function LabelColumnIndex() As Long

Sorting and formatting

sort-translations #

Sort the translations by their primary language column.

Signature:

Private Sub SortTranslations()

apply-formatting #

Apply light formatting and duplicate highlighting once per update.

Signature:

Private Sub ApplyFormatting()

Data exchange

export #

Export translations into a destination workbook.

Signature:

Public Sub Export(ByVal exportWorkbook As Workbook, Optional ByVal Hide As Long = xlSheetVisible)

Registry bookkeeping

next-update-sequence #

Retrieve and increment the registry update sequence.

Signature:

Private Function NextUpdateSequence(ByVal registrySheet As Worksheet) As Long

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)

counter-numeric-value #

Retrieve the current counter value stored in worksheet names.

Signature:

Private Function CounterNumericValue(ByVal registrySheet As Worksheet) As Long

hidden-name-store #

Create a HiddenNames wrapper for the supplied registry sheet.

Signature:

Private Function HiddenNameStore(ByVal registrySheet As Worksheet) As IHiddenNames

metadata-store #

Resolve the hidden name store hosting metadata.

Signature:

Private Function MetadataStore() As IHiddenNames

Validation and utilities

validate-initialised #

Ensure the manager has been initialised before use.

Signature:

Private Sub ValidateInitialised()

validate-translation-table #

Validate the supplied translations table.

Signature:

Private Sub ValidateTranslationTable(ByVal translationTable As ListObject)

validate-registry-sheet #

Validate the registry sheet before processing.

Signature:

Private Sub ValidateRegistrySheet(ByVal registrySheet As Worksheet)

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

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.


initialise #

Signature:

Private Sub ISetupTranslationsTable_Initialise(ByVal translationTable As ListObject, Optional ByVal stateScope As IApplicationState)

Used in (10 file(s))