Yeah i couldn't understand how it was set up in the concern. I deduced the
functionality ok.
There was a case where a user i was  using had nil for selected and
detected lanugage. This broke the setup.
In practice i don't know its possible to have nil any more with detected
language. Closed for anyway
On 22/04/2014 9:20 pm, "James Kiesel" <notifications@github.com> wrote:

> In app/services/translation_service.rb:
>
> > +    model.class.translatable_fields.each do |field|
> > +      translation.fields[field.to_s] ||= @translator.translate(model.send(field), from: model.language_field, to: to)
> > +    end
> > +    translation.save
> > +    translation
> > +  end
> > +
> > +  def self.available?
> > +    ENV.fetch('BING_TRANSLATE_APPID', nil) &&
> > +    ENV.fetch('BING_TRANSLATE_SECRET', nil) &&
> > +    true # don't return the secret!
> > +  end
> > +
> > +  def self.can_translate?(translatable)
> > +    self.available? &&
> > +    translatable.language_field != nil &&
>
> language_field just calls whatever field we pass in for that object type.
> The default is language, but you can specify which field.
>
> We don't actually use this customization anywhere just yet (but maybe down
> the road we want to use the user_language field instead of the languagefield for something.)
>
> So, translatable.language_field is the same as saying group.language,
> motion.language, etc.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/loomio/loomio/pull/1360/files#r11844256>
> .
>