diff --git a/plugin/rbx_dom_lua/src/customProperties.lua b/plugin/rbx_dom_lua/src/customProperties.lua index aa03310d5..d0f637239 100644 --- a/plugin/rbx_dom_lua/src/customProperties.lua +++ b/plugin/rbx_dom_lua/src/customProperties.lua @@ -1,4 +1,41 @@ local CollectionService = game:GetService("CollectionService") +local HttpService = game:GetService("HttpService") + +local function getContents(localizationTable) + local array = {} + for index, entry in ipairs(localizationTable:GetEntries()) do + local newEntry = {} + for key, value in pairs(entry) do + if key == "Context" or key == "Example" then + continue + end + + newEntry[string.lower(key)] = value + end + + array[index] = newEntry + end + + return HttpService:JSONEncode(array) +end + +local function setContents(localizationTable, contents) + local newContents = {} + for index, entry in ipairs(HttpService:JSONDecode(contents)) do + local newEntry = { + Context = "", + Example = "", + } + + for key, value in pairs(entry) do + newEntry[string.gsub(key, "^%a", string.upper)] = value + end + + newContents[index] = newEntry + end + + localizationTable:SetEntries(newContents) +end -- Defines how to read and write properties that aren't directly scriptable. -- @@ -6,12 +43,12 @@ local CollectionService = game:GetService("CollectionService") return { Instance = { Tags = { - read = function(instance, key) + read = function(instance) local tagList = CollectionService:GetTags(instance) return true, table.concat(tagList, "\0") end, - write = function(instance, key, value) + write = function(instance, _, value) local existingTags = CollectionService:GetTags(instance) local unseenTags = {} @@ -35,13 +72,13 @@ return { }, LocalizationTable = { Contents = { - read = function(instance, key) - return true, instance:GetContents() + read = function(instance) + return true, getContents(instance) end, - write = function(instance, key, value) - instance:SetContents(value) + write = function(instance, _, value) + setContents(instance, value) return true end, }, }, -} \ No newline at end of file +}