The deep magic of [[brackets]]
Apr. 2nd, 2009 02:33 pm![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
There's been some confusion as to how things in [[brackets]] work in the translation system, so I'd like to try to clarify.
In the code for a BML page, there are references to all the translation strings, which basically mean "when you get to this point in the code, look up that text of the translation string, and put it here". In the code, there can also optionally be a way to pass a variable to the translation string. Let me try to explain.
In the code, there might be a variable called $username, which contains the username of some account that we're doing something with. We might want to have a sentence like "Add $username to your access list". We could do this by making "Add" be one translation string and "to your access list" be another, and putting our variable in the middle but this is all sorts of bad and messy and likely to lead to strife. So instead, what we do is tell the code to write out some translation string except that when it encounters [[user]] in the translation string, it replaces it with whatever the code has in $username at the moment.
As such, things in brackets will work only if the code has been explicitly written to allow them to work in a given translation string. In our example above, we couldn't then use [[user]] in some other translation string as the code wouldn't be expecting it. We also couldn't change [[user]] to [[lemming]] and expect it to still work. It will only work with the exact right word in the exact right translation string.
Non-technical summary: Things in [[brackets]] are deep magic. If you see them, don't touch them. Don't try adding them in yourself, because it won't work.
In the code for a BML page, there are references to all the translation strings, which basically mean "when you get to this point in the code, look up that text of the translation string, and put it here". In the code, there can also optionally be a way to pass a variable to the translation string. Let me try to explain.
In the code, there might be a variable called $username, which contains the username of some account that we're doing something with. We might want to have a sentence like "Add $username to your access list". We could do this by making "Add" be one translation string and "to your access list" be another, and putting our variable in the middle but this is all sorts of bad and messy and likely to lead to strife. So instead, what we do is tell the code to write out some translation string except that when it encounters [[user]] in the translation string, it replaces it with whatever the code has in $username at the moment.
As such, things in brackets will work only if the code has been explicitly written to allow them to work in a given translation string. In our example above, we couldn't then use [[user]] in some other translation string as the code wouldn't be expecting it. We also couldn't change [[user]] to [[lemming]] and expect it to still work. It will only work with the exact right word in the exact right translation string.
Non-technical summary: Things in [[brackets]] are deep magic. If you see them, don't touch them. Don't try adding them in yourself, because it won't work.