In all honesty, there's no need to localize a UI object's name since most if not all of the time, the only thing referencing the object is the addon itself.
As far as setting the text, you can have code in the OnLoad handler set it to the contents of a table element.
Note you need to have the table and element(s) defined in a Lua file before the XML file is loaded in the TOC.
Here is an example:
xml Code:
<Button name="SomeButton" parent="SomeFrame" inherits="UIPanelButtonTemplate">
<Scripts>
<OnLoad>
self:SetText(NameSpace.L.VarName);
</OnLoad>
</Scripts>
</Button>
If you want to add a bit of hierarchy to the names, the UI system allows use of
$parent to stand in for the name of the object's parent. So if you decided to change the name of the button to say
$parentButton, it'll create the button named
SomeFrameButton.
If you don't plan on accessing the button outside of its own scripts or a script of one of its children, it's wise to not give it a name.