Q:

I18n - locale file - use ruby - use translation()

In a I18n locale file (eg el.yml): 

can I use translation method in order to use an already defined translation?
can I use ruby code inside?

For example, in the locale yml file, in several places I want to use the word "Invalid". So one approach is to translate the word "Invalid" each time 
Another approach is to translate it once, at the top, and then in each translation inside the locale yml which contains this word I could use something like t(:invalid)..
eg:
el:
  # global translations - in order to be used later in the file
  locked: 'kleidomeno'
  invalid: 'mi egiro'
  password: 'kodikos'

  devise:
    failure:
      invalid: "#{Invalid} %{authentication_keys} or #{password}."
      locked: "Your account is #{locked}."
      last_attempt: "You have one more attempt before your account is #{locked}."
      not_found_in_database: "#{invalid} %{authentication_keys} ή #{password}."

A:

can I use translation method in order to use an already defined translation?

Yes, that's what I18n translation comes for, e.g.
t 'something'

can I use ruby code inside?

No, it's a .yml file, which does not accept Ruby or any other programming languages.

Another approach is to translate it once

To translate once, you can write a new Rake task to generate the target yml for you.
Or maybe, wrap the official translation function with a new method, which can recognize your custom string syntax:
# custom translate
def ct(msg)
  msg.gsub(/#\{\s*([^\}]+)\s*\}/) {|_| t $1}
end

Call it like:
ct 'Your account is #{locked}.'

I think you'd better remove these failure strings out of your yml file if so.

